MERGE tbTable01 AS t
USING @tbRecords AS r ON t.Col01 = r.Col01
WHEN MATCHED THEN
UPDATE SET Col02 = r.Col02,
Col03 = r.Col03
WHEN NOT MATCHED THEN
INSERT (Col01,Col02)
VALUES (Col01,Col02);
Sources:
https://docs.microsoft.com/en-us/sql/t-sql/statements/merge-transact-sql?view=sql-server-ver15
Comments