OUTPUT Clause

SQL Server supports returning output from a data modification statement via the OUTPUT clause. The OUTPUT clause is supported for INSERT, DELETE, UPDATE, and MERGE statements. In the OUTPUT clause, you can refer to the special tables inserted and deleted. These special tables contain the rows affected by the data modification statement—in their new (after-modification) and old (before-modification) versions, respectively. You use the inserted and deleted tables here much like you do in triggers. With INSERTs, you refer to the inserted table to identify attributes from the new rows. With DELETEs, you refer to the deleted table to identify attributes from the old rows. With UPDATEs, you refer to the deleted table to identify the attributes ...

Get Inside Microsoft® SQL Server® 2008: T-SQL Querying now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.