SQL Server blocking: find the head blocker, even when it is sleeping
By Scott Coffey, Senior Database Developer. Updated 2026-10-27.
Users report that the application has frozen. In SSMS you run sp_who2 and the BlkBy column shows session 93 blocked by 91, and session 92 blocked by 93. Activity Monitor shows waits like LCK_M_X and LCK_M_S climbing. Nothing has errored; everything is waiting.
The session you need is the head blocker: the one that is blocking others but is not blocked itself. Killing or tuning anything further down the chain does not help, because those sessions are victims.
Why the obvious query misses it
Most blocking queries start from sys.dm_exec_requests. That view only has rows for sessions that are currently running a request. A very common head blocker is a session that ran BEGIN TRAN, changed some rows, and then went idle without committing: an application that opened a transaction and is waiting on a user or a web call, or someone who ran half a script in SSMS and went to lunch. That session is sleeping, it has no row in sys.dm_exec_requests, and it still holds every lock it took. To see it you have to start from sys.dm_exec_sessions.
The queries below are read-only. They need VIEW SERVER STATE, or VIEW SERVER PERFORMANCE STATE on SQL Server 2022 and later.
Step 1: list what is blocked
SELECT r.session_id, r.blocking_session_id, r.wait_type,
r.wait_time AS wait_ms, r.wait_resource,
DB_NAME(r.database_id) AS database_name,
LEFT(t.text, 200) AS running_sql
FROM sys.dm_exec_requests AS r
OUTER APPLY sys.dm_exec_sql_text(r.sql_handle) AS t
WHERE r.blocking_session_id <> 0
ORDER BY r.wait_time DESC;
Each row is a waiting request and the session it waits on. Follow the blocking_session_id values upward. A blocker can itself be blocked: a SELECT can wait behind an UPDATE that is queued for the same key, so the session named in its row is not always the root cause.
Negative values have special meanings. -2 means the lock is held by an orphaned distributed transaction, -3 a deferred recovery transaction, and -4 a latch owner that could not be determined at that moment. Those are not ordinary sessions you can look up.
Step 2: find the head blocker
SELECT s.session_id, s.login_name, s.host_name, s.program_name,
s.status AS session_status, r.status AS request_status,
s.open_transaction_count, s.last_request_end_time,
ib.event_info AS last_batch
FROM sys.dm_exec_sessions AS s
LEFT JOIN sys.dm_exec_requests AS r ON r.session_id = s.session_id
OUTER APPLY sys.dm_exec_input_buffer(s.session_id, NULL) AS ib
WHERE s.session_id IN (SELECT blocking_session_id
FROM sys.dm_exec_requests
WHERE blocking_session_id > 0)
AND ISNULL(r.blocking_session_id, 0) = 0; -- blocking others, not blocked
The LEFT JOIN is the point. A sleeping head blocker comes back with session_status = sleeping, a NULL request_status, and open_transaction_count of 1 or more. That combination means an uncommitted transaction left open. last_request_end_time tells you how long it has been idle, and last_batch from sys.dm_exec_input_buffer shows the last statement the client sent, which is usually enough to recognise the application or the script.
If the head blocker is running instead, it is doing real work, often a long update or a scan that holds locks while it runs. That is a query or indexing problem, not a forgotten transaction.
Step 3: check how old the transaction is
SELECT st.session_id, at.name AS transaction_name,
at.transaction_begin_time,
DATEDIFF(SECOND, at.transaction_begin_time, SYSDATETIME()) AS open_seconds
FROM sys.dm_tran_session_transactions AS st
JOIN sys.dm_tran_active_transactions AS at
ON at.transaction_id = st.transaction_id
WHERE st.session_id = 91; -- the head blocker from step 2
A transaction named user_transaction was opened explicitly with BEGIN TRAN. The age tells you roughly how much work a rollback might have to undo.
Step 4: see what is locked
The wait_resource from step 1 looks like KEY: 6:72057594045726720 (8194443284a0): database id, then a hobt id. Resolve the hobt id to a table and index in that database:
SELECT OBJECT_SCHEMA_NAME(p.object_id) AS schema_name,
OBJECT_NAME(p.object_id) AS table_name,
i.name AS index_name
FROM sys.partitions AS p
JOIN sys.indexes AS i ON i.object_id = p.object_id AND i.index_id = p.index_id
WHERE p.hobt_id = 72057594045726720;
An OBJECT wait resource carries an object id directly, which you can pass to OBJECT_NAME with the database id.
Step 5: resolve it, least risky option first
If the head blocker is a person or a known application, the cleanest fix is for that client to commit or roll back. Use the login, host, and program from step 2 to find the owner. If it is an application that routinely leaves transactions open, the lasting fix belongs in the application code, not on the server.
When you cannot wait, KILL ends the session and rolls back its open transaction. The rollback can take as long as the original work did, and the locks stay held until it finishes. Record the session id, the login, the last batch, and the reason before you run it:
KILL 91;
KILL 91 WITH STATUSONLY; -- progress report while a rollback is still running
Never kill a session just because it appears in a blocking chain. Confirm it is the head blocker first, or you roll back a victim and the real blocker keeps its locks.
Step 6: catch it next time
Blocking is often gone by the time someone looks. The blocked process report records any block that lasts longer than a threshold you set, in seconds:
EXEC sys.sp_configure N'show advanced options', 1; RECONFIGURE;
EXEC sys.sp_configure N'blocked process threshold (s)', 20; RECONFIGURE;
CREATE EVENT SESSION [blocked_process] ON SERVER
ADD EVENT sqlserver.blocked_process_report
ADD TARGET package0.event_file (SET filename = N'blocked_process')
WITH (STARTUP_STATE = ON);
ALTER EVENT SESSION [blocked_process] ON SERVER STATE = START;
Each event holds XML for both the blocked and the blocking process, including the input buffers, so you can review it after the fact. Pick a threshold that suits your workload; 20 seconds here is only an example. The SQL Rig blocking-chain.sql script walks the full chain recursively from sys.dm_exec_sessions and labels the head blocker, so sleeping blockers show up at level 0 with the chain beneath them.