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)
 Transact-SQL "IN" question

Author  Topic 

Scott W
Starting Member

3 Posts

Posted - 2005-08-28 : 16:12:57
Is there any way to do a Transact-SQL query using IN and have it return the value for the first match instead of all matches?

Example:


SELECT X FROM Table_X
WHERE Culture IN ('fr-ca', 'fr, 'eng-US', 'en');


Only instead of returning rows where Culture is 'fr-ca' or 'fr' or 'eng-US' or 'en', I want only rows that match 'fr-ca', or if there aren't any, those matching 'fr', then if not any, 'en-US', then finally 'en'.

I actually don't care if it uses IN or not, so long as it returns the right results.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-29 : 00:54:47
Then dont use in and use Where Culture ='fr-ca'


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

mmarovic
Aged Yak Warrior

518 Posts

Posted - 2005-08-29 : 04:11:17
Start with:
Declare table inList
(inListID identity(1,1),
value varchar(20))
Then insert cultures in desired order. The rest you can figure out yourself.
Go to Top of Page
   

- Advertisement -