Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 select particular records from a set composite key records

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-09-21 : 07:25:36
Rajdeep writes "Dear SQL Team,

Table A

SDDOCO* SDDCTO* SDKCOO* SDLNID* SDNXTR
2478 SO 00001 1.000 999
2478 SO 00001 2.000 999
2478 SO 00001 3.000 999
2478 SO 00200 4.000 540
2478 SO 00200 5.000 560

Pl. refer to the table above, the table has a composite primary index with 4 keys SDDOCO,SDDCTO, SDLNID, SDKCOO. We want to select only those records which have SDNXTR = '999'. So in the above table only the first 3 records should be chosen and not the later 3. Pl. suggest how to do that.

Thanks,
Rajdeep"

homebrew
Posting Yak Master

114 Posts

Posted - 2005-09-21 : 16:17:05
select * from TableA where SDNXTR = '999'
Go to Top of Page

rheitzman
Starting Member

16 Posts

Posted - 2005-09-21 : 19:45:39
You can always do a Where SDNXTR = '999' but of course it wouldn't use the PK.

You would have to add a key on SDNXTR if to need to avoid a full table scan unless you have some other Where clause items to limit the search.

Did I misunderstand the question?
Go to Top of Page
   

- Advertisement -