I have 2 columns that makes a record unique, so I want to merge with multiple keys. How can I do this?
I tried this but it doesnt seem to work:
MERGE INTO TABLE1 AS DST
USING TABLE2 AS SRC
ON SRC.pk1 = DST.pk1
AND
SRC.pk2 = DST.pk2
WHEN NOT MATCHED THEN
INSERT (pk1, pk2, Description)
VALUES (SRC.p1, SRC.pk2, SRC.Description)
;
What you have here will insert rows from
table2totable1. Except for a typo in the values clause you have it. ChangeSRC.p1toSRC.pk1.Try here: https://data.stackexchange.com/stackoverflow/q/120421/