SQL Server Interview Question #153

What is a deadlock?

Transactions, Locking, Blocking & Deadlocks Senior Advanced

Detailed Explanation

A deadlock occurs when two or more sessions form a cycle in which each is waiting for a resource held by another session in that cycle, so none can proceed.

SQL Server detects deadlocks and selects one transaction as the deadlock victim. That transaction is rolled back and receives error 1205, allowing the other transaction or transactions to continue.

A deadlock is different from ordinary blocking: blocking can resolve when the blocking transaction completes, while a deadlock contains a dependency cycle that requires intervention by SQL Server.