SQL Server · SQL
SELECT r.session_id AS blocked_session,
r.blocking_session_id AS blocking_session,
r.wait_type,
r.wait_time / 1000 AS wait_seconds,
s.login_name,
s.program_name,
LEFT(t.text, 200) AS blocked_query
FROM sys.dm_exec_requests r
JOIN sys.dm_exec_sessions s ON s.session_id = r.session_id
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) t
WHERE r.blocking_session_id <> 0
ORDER BY r.wait_time DESCThis query is part of the "SQL Server health" pack: connect the database in DataRunner and install the whole pack — queries, dashboard and checks — at once.
- Check that ships with it: No blocked session