Wednesday 20 July 2016

How to Delete using INNER JOIN with SQL Ser

DELETE FROM WorkRecord2 INNER JOIN Employee ON EmployeeRun=EmployeeNo
Where Company = '1' AND Date = '2013-05-06'

Error - Msg 156, Level 15, State 1, Line 15 Incorrect syntax near the keyword 'INNER'.


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 = '1' AND Date = '2013-05-06'