Are there any updates in SQL Server 2008 to allow a variable for the IN
clause of a WHERE
predicate?
Will this code work as expected?
declare @InParams varchar(100) = '1,2';
select * from Catego开发者_StackOverflow中文版ry
where CategoryID in @InParams;
See here: Arrays and Lists in SQL Server (pick your version), or here http://www.sommarskog.se/dynamic_sql.html
No - still need to use either:
- a split function, Table Valued CLR or Table Valued function
- dynamic SQL
精彩评论