SQL Server has an OUTPUT
clause that we can use any time we do an INSERT
, UPDATE
, DELETE
, or MERGE
operation. It allows us to retrieve information from modified rows during such operations. This can be especially useful for auditing, logging, or understanding the impact of database changes without needing an additional query.
Let’s look at how the OUTPUT
clause can help us log the data changes in our database.