>Hi Naomi
>Thanks for replying.
>So when you say two 'Virtual' tables, are there two tables created as part of the Output, or two different rows ?
>Any good examples around where a MERGE is used to 'Update' data ?
>Tia
>Gerard
>
>
I believe BOL has very good examples of how to use merge and OUTPUT.
If you either wrote a trigger, you know that there are two virtual tables you can access that contain all rows that were changed by the command that caused the trigger. In case of DELETE command all deleted rows will be in Deleted table. In case of INSERT command all new rows will be in INSERTED table. In case of UPDATE all original values (before update) will be in Deleted table and new values in the Inserted table.
Since MERGE command can perform all these actions, all these tables will contain changed rows. Also, as part of the OUTPUT clause you can get $Action to know what is the particular action these rows belong to (in other words, were they part of UPDATE or INSERT or DELETE).
If it's not broken, fix it until it is.
My Blog