将join与delete语句一起使用时的语法错误

时间:2019-05-01 23:11:52

标签: sql sql-server

无法弄清楚为什么我在此delete语句中遇到语法错误:

DELETE FROM RawServiceNow.dbo.u_loan
LEFT JOIN RawServiceNow.stg.ServiceNowDeletes ON 
RawServiceNow.stg.ServiceNowDeletes.SysId = RawServiceNow.dbo.u_loan.SysId WHERE 
ServiceNowDeltes.SysId IS NULL

错误:

  

消息156,级别15,状态1,第18行关键字附近的语法不正确   “左”。

1 个答案:

答案 0 :(得分:2)

这是正确的语法:

DELETE u
FROM RawServiceNow.dbo.u_loan u
LEFT JOIN RawServiceNow.stg.ServiceNowDeletes s 
ON s.SysId = u.SysId 
WHERE s.SysId IS NULL