Assign a list of integers to an @var

前端 未结 2 1585
一个人的身影
一个人的身影 2021-01-13 17:18

I can:

declare @idOrder int
set @idOrder = 21319

I want:

declare @idOrder int
set @idOrder = (21319, 21320)
2条回答
  •  执笔经年
    2021-01-13 18:04

    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)
    

提交回复
热议问题