Montag, 26. September 2011

MS SQL Server 2008 R2: view blocking chain head

Problem: If you have some processes erecting a blocking chain, you want to evaluate which process will be at the head of blocking chain.

Solution: Execute the following statement :

SELECT DISTINCT blocking_session_id
FROM sys.dm_exec_requests AS r
WHERE NOT EXISTS (SELECT 1
                  FROM sys.dm_exec_requests r2
                  WHERE r.blocking_session_id = r2.session_id
                  AND r2.blocking_session_id > 0)
AND r.blocking_session_id > 0                            ;
GO

Keine Kommentare: