Upsert example:
SELECT
id,
name,
age
FROM
TableA
UNION ALL
SELECT
id,
name,
age
FROM
TableB As b
WHERE
NOT EXISTS
(
SELECT *
FROM TableA As a
WHERE a.id = b.id
)
;
Similarly we can write MERGE and use the WHEN MATCHED and WHEN NOT MATCHED to do the insert/update.
What is difference between upsert approach using union all/non exists vs merge to load new data?