Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Syntax error when using join with delete statement [duplicate]

Tags:

sql

sql-server

Can't figure out why I'm getting a syntax error with this delete statement:

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

Error:

Msg 156, Level 15, State 1, Line 18 Incorrect syntax near the keyword 'LEFT'.

like image 774
PJ.SQL Avatar asked Jun 04 '26 18:06

PJ.SQL


1 Answers

This is the correct syntax:

DELETE u
FROM RawServiceNow.dbo.u_loan u
LEFT JOIN RawServiceNow.stg.ServiceNowDeletes s 
ON s.SysId = u.SysId 
WHERE s.SysId IS NULL
like image 82
forpas Avatar answered Jun 07 '26 09:06

forpas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!