Last active
December 12, 2020 19:27
-
-
Save ezhov-da/f027a44d74121fd6bf480ced793df2fd to your computer and use it in GitHub Desktop.
sql mssql merge
This file contains 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
--==> https://msdn.microsoft.com/ru-ru/library/bb510625.aspx | |
MERGE Production.UnitMeasure AS target | |
USING (SELECT @UnitMeasureCode, @Name) AS source (UnitMeasureCode, Name) | |
ON (target.UnitMeasureCode = source.UnitMeasureCode) | |
WHEN MATCHED THEN | |
UPDATE SET Name = source.Name | |
WHEN NOT MATCHED THEN | |
INSERT (UnitMeasureCode, Name) | |
VALUES (source.UnitMeasureCode, source.Name) | |
OUTPUT deleted.*, $action, inserted.* INTO #MyTempTable; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment