The INSERT OVER DML Syntax

As you just saw, the MERGE statement supports the OUTPUT clause to access the INSERTED and DELETED pseudo-tables, as well as a special $action string value that returns ‘INSERT’, ‘UPDATE’, or ‘DELETE’ according to the action performed for each row processed by the merge operation.

The results generated by the OUTPUT clause can be captured in another table or table variable using OUTPUT…INTO, making it possible to easily maintain historical records of changes in the database. However, because using OUTPUT…INTO dumps every row captured by the clause into the destination table or table variable, it is not possible to filter on this data.

A Filterable Alternative to OUTPUT…INTO

INSERT OVER DML refers to a special syntax in ...

Get Programming Microsoft® SQL Server® 2012 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.