I am attempting to execute the below syntax and I get two errors
A MERGE statement must be terminated by a semi-colon (;).
Incorrect syntax near '='.
Now if I comment out the last line of code which is an update statement the syntax executes perfectly. Is there a way to run both an
Update() statement in one
Here is syntax
MERGE INTO EmpSales es USING ( SELECT employee, COUNT(sales) as SaleCount FROM salesInfo WHERE [Sale Date] BETWEEN '01/01/2016' AND '12/31/2016' GROUP BY employee ) cs ON es.employee = cs.employee WHEN MATCHED THEN UPDATE SET es.TotalSales = cs.SaleCount WHEN NOT MATCHED BY TARGET THEN INSERT (employee, TotalSales) VALUES (cs.employee, cs.SaleCount) UPDATE SET es.Madrigal = '0';