我有多个删除语句要在 SQL Server 2008 R2 上运行
DELETE FROM A WHERE A_id in (SELECT B_id FROM B WHERE B_name = 'Target')
DELETE FROM B WHERE B_id in (SELECT B_id FROM B WHERE B_name = 'Target')
DELETE FROM C WHERE C_id in (SELECT B_id FROM B WHERE B_name = 'Target')
DELETE FROM D WHERE D_id in (SELECT B_id FROM B WHERE B_name = 'Target')
有没有办法可以使用变量来替换重复的子查询?是否有这样的变量类型来保存子查询或其结果?
谢谢