Skip to content

Instantly share code, notes, and snippets.

@tdmitch tdmitch/merge3.sql
Created Jun 1, 2018

Embed
What would you like to do?
MERGE etl.Change_Tracking_Version AS target
USING (
SELECT 'Emp' [Table_Name]
, @EndVersionID [Version_ID] -- Get the change tracking version ID
) AS source
ON target.Table_Name = source.Table_Name
-- Update existing value
WHEN MATCHED THEN UPDATE
SET target.Change_Tracking_Version = source.Version_ID
-- No match? Insert
WHEN NOT MATCHED
THEN INSERT (Table_Name, Change_Tracking_Version)
VALUES (source.Table_Name, source.Version_ID);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.