开发者

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

开发者 https://www.devze.com 2022-12-30 18:14 出处:网络
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?

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

精彩评论

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