what is the use of output $action in Merge statement in Sql server 2008?
You can also use a CTE in a CREATE a view, as part of the view's SELECT query. In addition, as of SQL Server 2008, you can add a CTE to the new MERGE statement. After you define your WITH clause with the CTEs, you can then reference the CTEs as you would refer any other table.
A MERGE statement cannot UPDATE/DELETE the same row of the target table multiple times. Refine the ON clause to ensure a target row matches at most one source row, or use the GROUP BY clause to group the source rows.
A single MERGE statement can also combine both DELETE and INSERT operations, or can combine both UPDATE and INSERT operations without deleting any rows. The source table is unchanged by the MERGE statement.
The all-knowing MSDN says
$action
Is available only for the MERGE statement. Specifies a column of type nvarchar(10) in the OUTPUT clause in a MERGE statement that returns one of three values for each row: 'INSERT', 'UPDATE', or 'DELETE', according to the action that was performed on that row.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With