Back to results for “Transactions & ACID”
SQL Server › Deadlocks

How does SQL Server decide which transaction becomes the deadlock victim?

Beginner

Answer

SQL Server generally chooses the transaction that is cheapest to roll back based on the amount of work already done, unless a session has been given a higher deadlock priority, in which case a lower priority session is chosen as the victim instead, regardless of cost.
SET DEADLOCK_PRIORITY LOW;
-- This session will be chosen as the victim before others
-- with normal or high priority
Real-world example A reporting job is given a low deadlock priority so that if it ever conflicts with a more important order processing transaction, the reporting job is the one automatically rolled back instead.

Common follow-ups: What deadlock priority values are available besides LOW and HIGH?;Does setting a low priority guarantee that session will never cause a deadlock?