为什么我不能这样做:
declare @myTempTableList TABLE (
CommId int
)
insert into @myTempTableList (CommId)
VALUES
(742), (803)
delete from myRealTable where MyRealTableId in (
select mrt.MyRealTableId from MyRealTable mrt
where commId in (@myTempTableList)
)
它告诉我必须声明标量变量@myTempTableList
答案 0 :(得分:1)
delete from myRealTable where MyRealTableId in (
select mrt.MyRealTableId from MyRealTable mrt
where commId in (SELECT CommId FROM @myTempTableList)
)
试试上面的
答案 1 :(得分:1)
DELETE FROM myRealTable
WHERE EXISTS (SELECT 1
FROM @myTempTableList
WHERE myRealTable.MyRealTableId = @myTempTableList.CommId)