SQL Server › Deadlocks
How does SQL Server decide which transaction becomes the deadlock victim?
BeginnerAnswer
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 priorityReal-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.