Here’s the simplest example of a working Merge statement I could make. Its great to build-on to test the formatting of ‘real’ merges.
drop table d, s -- destination table containing old data create table d (id int, fruit varchar(50), tasty int) insert into d values (1,'apple', 5), (2,'orange', 5) select * from d -- source table containing unchanged, updated, and new data create table s (id int, fruit varchar(50), tasty int) insert into s values (1, 'apple', 5), (2,'orange', 0), (3,'banana', 9) select * from s --merge statement merge d target using s source on target.id = source.id when matched then update set tasty = source.tasty when not matched then insert values (id, fruit, tasty); -- show new destination table select * from d