Last active
June 18, 2016 13:33
-
-
Save kkoziarski/bb9831cde953836df9ae4ab5eb6974be to your computer and use it in GitHub Desktop.
Script.PostDeployment.sql update or insert (MERGE)
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 [TABLE_NAME] | |
USING (VALUES | |
(1, 'some text', 'some value'), | |
(2, 'some text', 'some value') | |
) | |
AS Source ([ID], [Text], [Value]) | |
ON [TABLE].[ID] = Source.[ID] | |
-- update matched rows | |
WHEN MATCHED THEN | |
UPDATE SET | |
[Text] = Source.[Text], | |
[Value] = Source.[Value] | |
-- insert new rows | |
WHEN NOT MATCHED BY TARGET THEN | |
INSERT ([ID], [Text], [Value]) | |
VALUES ([ID], [Text], [Value]) | |
--Script.PostDeployment.sql | |
--BEGIN | |
--:r .\Data\post_data.sql | |
--END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment