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.

How to Delete using INNER JOIN with SQL Server?的更多相关文章

  1. INNER JOIN与LEFT JOIN在SQL Server的性能

    我创建了INNER JOIN 9桌,反正需要很长的(超过五分钟).所以,我的民歌改变INNER JOIN来LEFT JOIN LEFT JOIN的性能较好,在首次尽管我所知道的.之后我变了,查询的速度 ...

  2. Microsoft SQL Server Trace Flags

    Complete list of Microsoft SQL Server trace flags (585 trace flags) REMEMBER: Be extremely careful w ...

  3. Microsoft SQL Server Version List [sqlserver 7.0-------sql server 2016]

    http://sqlserverbuilds.blogspot.jp/   What version of SQL Server do I have? This unofficial build ch ...

  4. Microsoft SQL Server Version List(SQL Server 版本)

    原帖地址 What version of SQL Server do I have? This unofficial build chart lists all of the known Servic ...

  5. SQL Server Column Store Indeses

    SQL Server Column Store Indeses SQL Server Column Store Indeses 1. 概述 2. 索引存储 2.1 列式索引存储 2.2 数据编码和压缩 ...

  6. SQL Server基础知识

    1.SQL Server表名为什么要加方括号? 这个不是必须要加,但表名或字段名如果引用了sqlserver中的关键字,数据库会不识别这到底是关键字还是表名(或字段名)时就必须要加. 比如,一个表名叫 ...

  7. Part 7 Joins in sql server

    Joins in sql server Advanced or intelligent joins in sql server Self join in sql server Different wa ...

  8. SQL Server 性能调优 之运行计划(Execution Plan)调优

    运行计划中的三种 Join 策略 SQL Server 存在三种 Join 策略:Hash Join,Merge Join,Nested Loop Join. Hash Join:用来处理没有排过序/ ...

  9. SQL Server中UPDATE和DELETE语句结合INNER/LEFT/RIGHT/FULL JOIN的用法

    在SQL Server中,UPDATE和DELETE语句是可以结合INNER/LEFT/RIGHT/FULL JOIN来使用的. 我们首先在数据库中新建两张表: [T_A] CREATE TABLE ...

随机推荐

  1. Linux之(Git)服务之windows配置

    设置你自己的昵称与email设置本地机器默认commit的昵称与Email. 请使用有意义的名字与email. git config --global user.name "syavingc ...

  2. django 1.10以上版本,引入js

    引入js库 建立static文件夹:  注意上图里面static文件夹的路径,再在里面添加js文件夹,js文件夹里面就可以放我们需要的js文件了. 配置相关文件 接下来,想要使用这些js我们还需要进行 ...

  3. HttpWatch使用教程

    一 概述: HttpWatch强大的网页数据分析工具.集成在Internet Explorer工具栏.包括网页摘要.Cookies管理.缓存管理.消息头发送/接受.字符查询.POST 数据和目录管理功 ...

  4. php 工厂方法模式

    #使用工厂方法模式是不知道要创建类的对象有哪些.interface IFactory{ public function CreateOperation();#工厂方法模式只有单个产品 } class ...

  5. Android开发:使用DialogFragment实现dialog自定义布局

    使用DialogFragment实现dialog的自定义布局最大的好处是可以更好控制dialog的生命周期. TestFragment的代码: public class TestFragment ex ...

  6. 2014江西理工大学C语言程序设计竞赛高级组题解

    1001 Beautiful Palindrome Number 枚举回文数字前半部分,然后判断该数字是否满足,复杂度为O(sqrt(n))! 1002 Recovery Sequence  本题的核 ...

  7. iframe脸面的页面和父页面之间的交互方法

    1.iframe父页面修改iframe中的页面的信息 var obj = document.getElementById("iframeId").contentWindow;   ...

  8. Maven学习笔记—安装和配置

    Maven的安装和配置 1 在windows上安装maven 1.1 下载maven 访问maven的下载页面:http://maven.apache.org/download.cgi,选择版本下载即 ...

  9. 20171104 DOI Excel 导出

    1. OAOR 创建模板, Class name:SOFFICEINTEGRATIONClass type:  OTObject key:  ZZCSDRP_0030 2.双击表模板创建Excel 模 ...

  10. F110 参数保存和重新运行录屏

    **初始界面回车 PERFORM frm_dynpro USING ' 'X'. PERFORM frm_dynpro USING '' 'BDC_CURSOR' 'F110V-LAUFD'. PER ...