I use MERGEto insert or update records in a table:
MERGE INTO target
USING SELECT * FROM @source
WHEN MATCHED THEN
UPDATE SET ...columns...
WHEN NOT MATCHED THEN
INSERT ...columns...
OUTPUT inserted.* INTO @insertedRecord
If the above statement performs an update, is the updated record in the table variable updated?
source
share