Montag, 26. September 2011

MS SQL Server R2: view blocked processes

Problem: you want to create a query showing a list of blocked processes.

Solution: Execute the following statement:

SELECT r.session_id, r.status, r.blocking_session_id,
       r.command, r.wait_type, r.wait_time,    t.text
FROM sys.dm_exec_requests AS r
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) AS t
WHERE r.blocking_session_id > 1;
GO

Keine Kommentare: