https://stackoverflow.com/questions/16481379/how-to-delete-using-inner-join-with-sql-server

You need to specify what table you are deleting from, here is a version with an alias:

DELETE w
FROM WorkRecord2 w
INNER JOIN Employee e
ON EmployeeRun=EmployeeNo
WHERE Company = '' AND Date = '2013-05-06'

SQL Server不支持一次删除多张表中的数据

https://stackoverflow.com/questions/783726/how-do-i-delete-from-multiple-tables-using-inner-join-in-sql-server

You can take advantage of the "deleted" pseudo table in this example. Something like:

begin transaction;

   declare @deletedIds table ( id int );

   delete t1
output deleted.id into @deletedIds
from table1 t1
join table2 t2
on t2.id = t1.id
join table3 t3
on t3.id = t2.id; delete t2
from table2 t2
join @deletedIds d
on d.id = t2.id; delete t3
from table3 t3 ... commit transaction;

Obviously you can do an 'output deleted.' on the second delete as well, if you needed something to join on for the third table.

As a side note, you can also do inserted.* on an insert statement, and both inserted.* and deleted.* on an update statement.

EDIT: Also, have you considered adding a trigger on table1 to delete from table2 + 3? You'll be inside of an implicit transaction, and will also have the "inserted." and "deleted." pseudo-tables available.

最新文章

  1. C#检测本地网络状态
  2. Atitit (Sketch Filter)素描滤镜的实现  图像处理  attilax总结
  3. HDU4930 Fighting the Landlords 模拟
  4. 缓存技术比拼:Redis与Memcached的同与不同
  5. 管窥MVVMLight Command参数绑定和事件传递
  6. Effective Java之避免创建不必要的对象
  7. 迷宫问题python实现(靠右手摸墙)
  8. 连载:面向对象葵花宝典:思想、技巧与实践(33) - ISP原则
  9. Windows Ubuntu Bash申请免费通配符证书(Let's Encrypt)并绑定IIS
  10. vue学习记录③(路由)
  11. 什么是 IP 隧道,Linux 怎么实现隧道通信?
  12. MACE移植要求
  13. 已使用.netframework,version=v4.6.1 而不是目标框架netcoreapp,version=v2.1 还原包,此包可能与项目不完全兼容
  14. Pytorch Visdom
  15. Linux文件系统深度讨论【转】
  16. unigui1404在delphi10.2.2安装
  17. docker-部署elk-6.1.3
  18. Java基础-Java中的并法库之线程池技术
  19. 004.SMB之guest级别配置
  20. java.lang.Exception: Socket bind failed: [730048]

热门文章

  1. Mongo同步数据到Elasticsearch
  2. LIS(模板)
  3. Unit redis-server.service is masked.
  4. 删除datatable中的行
  5. JS添加标签
  6. Docker容器/镜像查看及删除操作
  7. 剑指offer 面试39题
  8. python默认参数不能定义为可变对象类型
  9. Python基础(18)_面向对象程序设计2(反射、__str__、__del__、__item__系列)
  10. vlc做转发的命令