Monday, September 9, 2024

How do I find blocked sessions and the session that is blocking them?

 To identify blocked sessions and the session causing the block:

SELECT blocking_session_id AS BlockingSession, session_id AS BlockedSession, wait_type, wait_time, wait_resource FROM sys.dm_exec_requests WHERE blocking_session_id <> 0;

This query shows all sessions that are currently blocked and the blocking session’s ID.