SQL Server で MERGE をやったのでメモ。
MERGE [my_tbl] AS t1 USING [my_tmp] AS t2 ON t1.[mykey] = t2.[mykey] WHEN MATCHED THEN UPDATE SET t1.[hoge] = t2.[hoge], t1.[fuga] = t2.[fuga] WHEN NOT MATCHED BY TARGET THEN INSERT([mykey], [hoge], [fuga]) VALUES(t2.[mykey], t2.[hoge], t2.[fuga]);
前にやった PostgreSQL での方法はこれ↓
PostgreSQL 12 で Merge っぽい事をやる