'Output Clause Explained
Please explain to me the SQL Server output clause.
Solution 1:[1]
It could be stated as
How do I find out what rows were deleted, inserted or updated?
You can using some fancy trigger code or a separate SELECT, but the OUTPUT clause make it effortless. The SELECT becomes part of the actual DELETE, INSERT or UPDATE
Solution 2:[2]
The OUTPUT clause allows you to combine an INSERT or UPDATE with a SELECT.
You can OUTPUT a list of fields, and the query will return one row for each row affected by the INSERT / UPDATE.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | gbn |
| Solution 2 | SLaks |
