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
 General SQL Server Forums
 New to SQL Server Programming
 select in list

Author  Topic 

craigmacca
Posting Yak Master

142 Posts

Posted - 2011-06-16 : 08:05:05
Hi i need to check if a Id is in a list of Ids, not sure how to do this??

DECLARE @SelectedList nvarchar(100)
set @SelectedList = '13, 17'

SELECT
CASE WHEN t.Id IN @SelectedList THEN
1
ELSE
0
END
AS IsOpen

ahmeds08
Aged Yak Warrior

737 Posts

Posted - 2011-06-16 : 08:23:37
try using this

DECLARE @A TABLE (COL INT)
INSERT INTO @A SELECT 13
INSERT INTO @A SELECT 17

SELECT
CASE WHEN t.Id IN (SELECT COL FROM @A) THEN
1
ELSE
0
END
AS IsOpen
Go to Top of Page
   

- Advertisement -