This MERGE Statement Quiz asks what happens when two source rows match one target row. The answer is error 8672, and the whole statement fails. A tested script shows the error, the fix with ROW_NUMBER and the same change written as UPDATE plus INSERT.
OUTPUT Clause Quiz: What Do inserted and deleted Hold?
This OUTPUT Clause Quiz raises a price from 10 to 12 and asks which two values come back. The answer is 10 and 12, because deleted holds the old row and inserted the new one. A tested script proves it and shows OUTPUT with INSERT, DELETE and an audit table.
Output Clause in Simple Examples: See the Rows You Just Changed
The OUTPUT clause shows the exact rows an INSERT, UPDATE or DELETE just changed, using the inserted and deleted tables. This post covers the output clause in simple examples with a small table of seed packets. It also shows how to save the rows with INTO, what error you get for the wrong table, and why triggers change the rules.
Destructive Reads: Pulling Work From a Queue Table With OUTPUT
Claiming a job and finishing it are two different things. Try a delete claim, a rollback, and an update claim on a tiny queue.
Delete Duplicate Rows in SQL Server and Keep One Copy
To delete duplicate rows in SQL Server and keep one copy, number the rows in each group with ROW_NUMBER and delete every row after the first. This post finds the duplicates first, previews the rows that will go, and deletes them inside a transaction while saving a copy of what was removed. It ends with a unique index on a cleaned column, so the same address can’t come back.





