WHEN NOT MATCHED THEN AS SOURCE( BusinessEntityID, AccountNumber, Name, CreditRating, PreferredVendorStatus, ActiveFlag) Depending upon the match, then INSERT, UPDATE, or DELETE statements are executed. Of course, before you run this I would test with a statement. This is the statement I would run to make sure what I m intending to delete is correct. SELECT BusinessEntityID, RateChangeDate The main advantage of using the statement is that when it executes it makes one pass through the data, as opposed to a pass for each operation( e.
three passes for separate INSERT, UPDATE, and DELETE operations). INSERT( BusinessEntityID, AccountNumber, Name, The basic idea is to perform an INSERT, UPDATE, or DELETE operation on the targetTable, using the sourceTable as input.