简体   繁体   中英

displace input row in Access 2003 and SQL Server 2000

Output in Access 2003:

ID | Description | Quantity | Title | Obj
--- ---------------- --------------------------------------------------

17 | 6 | 253000.00 | |
18 | 7 | 330000.00 | |
19 | 1 | 340000.00 | 8414 | 69327
22 | 2 | 120000.00 | 8414 | 69344
23 | 3 | 615000.00 | 8414 | 69327
24 | 4 | 320000.00 | 8414 | 69327
25 | 5 | 809500.00 | 8414 | 69327

Query :

SELECT      TVFundBillDetail.ID ,
            TVFundBillDetail.HID ,
            TVFundBillDetail.Description ,
            TVFundBillDetail.Quantity ,
            TVFundBillDetail.Title ,
            TVTitle.Name TitleName ,
            Obj ,
            TVAllObjects.Name ObjName
     FROM   TVFundBillDetail
            LEFT OUTER JOIN TVTitle ON TVFundBillDetail.Title = TVTitle.Code
            LEFT OUTER JOIN TVAllObjects ON TVFundBillDetail.Obj = TVAllObjects.Code

Problem: sequence of input row show in description column. when title and obj is null then displace sequence of input row. application is access 2003 and DBMS is SQL Server 2000

There are probably many ways to achieve this. For Access, you can simply use Nz() in your query, like this:

...
Nz(TVFundBillDetail.Title, "    ")
...

If Title is NULL , you'll get 4 spaces (or you can use "0000" if you prefer).

For SQL server, an equivalent function is COALESCE() :

...
COALESCE(TVFundBillDetail.Title, "    ")
...

If you're using the query as a normal Qccess query, the first one will work. If you're using a pass-through query, or exposing a SQL Server view, the second one will work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM