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. 第一篇:尽量多的以 const/enum/inline 替代 #define

    前言 在面向过程语言,如 C 语言中,#define 非常常见,也确实好用,值得提倡.但在如今面向对象的语言,如 C++ 语言中,#define 就要尽量少用了. 为何在 C++ 中就要少用了呢? 这 ...

  2. iOS提交到appstore的新要求

    本文转载至http://blog.csdn.net/kqygww/article/details/41277555     64-bit and iOS 8 Requirements for New ...

  3. Swift学习笔记(一):No such module 'Cocoa'

    在xcode中创建一个Playground文件, 进行导包操作 ,import Cocoa 却提示No such module 'Cocoa' 原因是该Playground文件的platform 设置 ...

  4. Eclipse: Android Device Chooser - Unknown Target

    公司最近所有的项目都使用到了Android开发手机(或PDA)应用.所需要的Android开发技术并不是非常复杂,因为我们的底层方法全部使用WebServcie写好了,做Android开发的人员只需要 ...

  5. HDU1688(Sightseeing)

    题目链接:传送门 题目大意:给你一幅图(单向边),找出从起点到终点有多少条不同路径(最短路或者比最短路长度大1) 题目思路:二维dijkstra,真的是要对dijkstra理解非常透彻才行,距离数组d ...

  6. 邱老师玩游戏(树形DP) UESTC - 1136

    邱老师最近在玩一种战略游戏,在一个地图上,有N座城堡,每座城堡都有一定的宝物,在每次游戏中邱老师允许攻克M个城堡并获得里面的宝物. 但由于地理位置原因,有些城堡不能直接攻克,要攻克这些城堡必须先攻克其 ...

  7. HTML 之 Table 表格详解

    HTML 之 Table 表格详解 HTML中的table可以大致分为三个部分: thead ---------表格的页眉 tbody ---------表格的主体 tfoot ---------定义 ...

  8. adobe flash player升级coredump分析

    flash player版本号:14.0.0.125 产品名称:Adobe® Flash® Player Installer/Uninstaller 系统:windows xp sp3 调试器:win ...

  9. Scilab 的画图函数(2)

    一幅图是由很多元素组成的. 包含图标题.x轴标签.y轴标签,刻度线等.图1给出了各个元素的一个示意图. 这些全部的元素在scilab中都是能够用代码控制的. 标题 上个笔记上介绍了用xtitle()函 ...

  10. 1、hive安装详细步骤

    一.环境准备 hadoop-2.7.2 java 1.7.0 apache-hive-1.2.1 mysql Hive配置文件介绍 •hive-site.xml      hive的配置文件 •hiv ...