views:

46

answers:

2

Are there any updates in SQL 2008 to allow a variable for the IN of a where clause?

Declare @InParams varchar(100)
Set @InParams = '1,2'

Select * from Category
Where CategoryID in @InParams
+5  A: 

No - still need to use either:

  • a split function, Table Valued CLR or Table Valued function
  • dynamic SQL
OMG Ponies
+5  A: 

See here: Arrays and Lists in SQL Server (pick your version), or here http://www.sommarskog.se/dynamic_sql.html

SQLMenace
+1 for links I didn't bother to post cuz you did already.
OMG Ponies