Skip to content

Instantly share code, notes, and snippets.

@admir-live
Created September 25, 2023 18:19
Show Gist options
  • Select an option

  • Save admir-live/bd2194990dd41e444048ec769f2ffcb0 to your computer and use it in GitHub Desktop.

Select an option

Save admir-live/bd2194990dd41e444048ec769f2ffcb0 to your computer and use it in GitHub Desktop.
Solution.sql
MERGE INTO target_table AS target
USING source_table AS source
ON target.id = source.id
WHEN MATCHED THEN
UPDATE SET target.column1 = source.column1, target.column2 = source.column2
WHEN NOT MATCHED THEN
INSERT (id, column1, column2) VALUES (source.id, source.column1, source.column2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment