title: SQL MERGE, Deleting each item from source after update or insert
body: <p>I have a temporary table which I use to insert many data into rapidly . Then I use a SQL merge to insert data from temp table into main table(Target Table). But I want to delete each record from source table as soon as inserted into target table. Something like the code below:</p>
  
  <pre><code>    MERGE Target AS T
      USING Source AS S
      ON (T.EmployeeID = S.EmployeeID) 
      WHEN NOT MATCHED BY TARGET AND S.EmployeeName LIKE 'S%' 
          THEN INSERT(EmployeeID, EmployeeName) VALUES(S.EmployeeID, S.EmployeeName)
          --THEN DELETE INSERTED ITEM------------------------------
      WHEN MATCHED 
          THEN UPDATE SET T.EmployeeName = S.EmployeeName
      WHEN NOT MATCHED BY SOURCE AND T.EmployeeName LIKE 'S%'
          THEN DELETE  
  </code></pre>