gpt4 book ai didi

sql - SQL Server 2008 可以在 WHERE IN 子句中使用变量吗

转载 作者:行者123 更新时间:2023-12-01 07:47:41 26 4
gpt4 key购买 nike

SQL Server 2008 中是否有任何更新允许 IN 的变量? WHERE的条款谓词?

这段代码会按预期工作吗?

declare @InParams varchar(100) = '1,2';

select * from Category
where CategoryID in @InParams;

最佳答案

看这里:Arrays and Lists in SQL Server (选择您的版本),或在这里 http://www.sommarskog.se/dynamic_sql.html

关于sql - SQL Server 2008 可以在 WHERE IN 子句中使用变量吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2870162/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com