开发者

Can SQL Server 2008 use a variable in a WHERE IN clause

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜