O'Reilly logo

Programming Microsoft® SQL Server® 2012 by Leonard Lobel and Andrew Brust

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required