本文介绍了将整数列表分配给@var的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以:
declare @idOrder int
set @idOrder = 21319
我想要:
declare @idOrder int
set @idOrder = (21319, 21320)
用于WHERE"子句使用 IN 运算符的一系列语句
for use in a series of statements where the 'WHERE' clause uses the IN operator
delete Orders
where idOrder in @idOrder
代替
delete Orders
where idOrder in (21319, 21320)
推荐答案
只要它是一个 int
,你就不能这样做,因为它不是该数据类型的有效值.可以采用多个整数的数据类型是 table
You can't do that as long as it's an int
, as that's not a valid value for that datatype. A datatype that could take several integers is a table
declare @idOrder table (id int)
insert into @idOrder values(21319)
insert into @idOrder values(21320)
delete from Orders where idOrder in (select id from @idOrder)
这篇关于将整数列表分配给@var的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!