Skip to content

Instantly share code, notes, and snippets.

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

What would you like to do?
MERGE etl.Change_Tracking_Version AS target
USING (SELECT 'Emp' [Table_Name]
, CHANGE_TRACKING_CURRENT_VERSION() [Version_ID] — Get the change tracking version ID
) AS source
ON target.Table_Name = source.Table_Name
WHEN MATCHED — Exists? Then update
SET target.Change_Tracking_Version = source.Version_ID
WHEN NOT MATCHED — No match? Insert
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.