Created
September 17, 2015 19:55
-
-
Save earino/fb259896cdffb060a6c3 to your computer and use it in GitHub Desktop.
merge example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MERGE INTO Inventory AS I | |
| USING Changes AS C | |
| ON I.Part = C.Part | |
| WHEN MATCHED AND | |
| I.Action = 'Mod' | |
| THEN UPDATE | |
| SET Qty = I.Qty + C.Qty | |
| WHEN NOT MATCHED AND | |
| I.Action = 'New' | |
| THEN INSERT (Part, Qty) | |
| VALUES (C.Part, C.Qty) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment