How to use the merge command to update and insert data from and into the same table
How to use the merge command to update and insert data from and into the same table? Merge variant: Automerge!
MERGE INTO MYTABLE AS A
USING (VALUES (1, 'ABCD')) AS A_TMP (ID, NAME)
ON A.ID = A_TMP.ID
WHEN MATCHED THEN
UPDATE SET NAME = 'EFGH'
WHEN NOT MATCHED THEN
INSERT (ID, NAME) VALUES (A_TMP.ID, A_TMP.NAME)
ELSE IGNORE;