What is the difference between blocking, locking and deadlocking?

SQL Server Transactions Intermediate 2–3 Yrs3–5 Yrs Conceptual 1 min read

Quick Answer

Locking is normal and constant — it's how SQL Server maintains isolation. Blocking is when one session must wait for another to release a lock; brief blocking is fine, sustained blocking is a problem. Deadlock is a cycle of blocking where neither can proceed, so the engine kills one.

Locking is just how the engine works — it's happening all the time to keep transactions isolated. Blocking is when one session has to wait for a lock another session holds; a moment of that is normal, but if it lasts seconds and chains up, that's a problem. A deadlock is a specific cycle — A waits on B, B waits on A — and SQL Server resolves it by killing one of them. To fix blocking I find the head blocker, then usually the cause is a transaction that's too long or a query with no good index that's locking way more rows than it needs.

  • Locking → expected. Blocking → a symptom (long transactions, missing indexes causing broad locks, low isolation-friendly design). Deadlock → a bug pattern (inconsistent access order).
  • Diagnose blocking: find the head blocker (the session at the root of the chain) with sys.dm_exec_requests / sp_WhoIsActive; look at wait_type = LCK_*.
  • Reduce blocking: shorter transactions, proper indexes (seek locks fewer rows), read-committed snapshot isolation, do slow work (HTTP, user input) outside the transaction.