1 2 3 4 5 6 7 8 9 | MERGE Target AS T USING Source AS S ON (T.ID = S.ID) WHEN NOT MATCHED BY TARGET THEN INSERT(ID, Name) VALUES(S.ID, S.Name) WHEN MATCHED AND EXISTS(Select S.* EXCEPT Select T.*) THEN UPDATE SET T.Name = S.Name WHEN NOT MATCHED BY SOURCE THEN DELETE |
Direct link: https://paste.plurk.com/show/2611101