SQL Server emergency? Email pinal@sqlauthority.com with URGENT in the subject line.

Record Checkout in SQL Server: A Visible Lock With an Expiry Time

Record checkout puts the name of the editor and an expiry time on the row, so a screen can show who has it. This post builds it with one UPDATE and proves it with two sessions that race for 2,000 rows. A check-then-update version gives some rows two winners, and the one-statement version never does. It also covers expired locks, late saves and check-in. Every result comes from SQL Server 2025.

Continue Reading

Reordering a List in SQL Server: Move One Row, Write One Row

Reordering a list in SQL Server means changing a sort key, and the best design writes the fewest rows. This post compares three designs for dragging an item to a new place: renumber everything, shift the rows in between, and leave gaps. Each one is measured by rows written on a list of 1,000 items. Every result comes from SQL Server 2025.

Continue Reading

Schema Snapshot: Prove a Deployment Script Is Safe to Run Twice

A schema snapshot records a table’s columns, indexes, constraints and rows, so you can prove a deployment script is safe to run twice. This post runs a plain script twice and watches a price change again. It then guards each step, runs the guarded script twice, and shows that the two snapshots match. Every result comes from SQL Server 2025.

Continue Reading

Retrying a Deadlock Victim: When the Retry Helps and When It Hurts

Retrying a deadlock victim works when the retry repeats the whole transaction. This post builds a bounded T-SQL retry for error 1205 and tests it against a real deadlock between two sessions. It then shows two cases where a retry does harm: inside an outer transaction and on an error that is not a deadlock. Every result comes from SQL Server 2025.

Continue Reading