Insert And Update Statement With Merge 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 Insert() and Update() statement in one Merge()

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';
It's not completely clear what you're trying to accomplish. However, it seems most likely that you're trying to update EmpSales.Madrigal to '0' after your insert.

To set EmpSales.Madrigal to '0' for all newly inserted records:

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, Madrigal)
  VALUES (cs.employee, cs.SaleCount, '0')
;


To set EmpSales.Madrigal to '0' for all inserted or updated records:

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, es.Madrigal = '0'
WHEN NOT MATCHED BY TARGET THEN
  INSERT (employee, TotalSales, Madrigal)
  VALUES (cs.employee, cs.SaleCount, '0')
;


If you're looking for something else, please clarify what you need.