Problem:
You want to create a query showing the T-SQL code behind a blocking process.
Solution:
Execute the following query:
SELECT t.text
FROM sys.dm_exec_connections AS c
CROSS APPLY sys.dm_exec_sql_text(c.most_recent_sql_handle) AS t
WHERE c.session_id = (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
Montag, 26. September 2011
MS SQL Server 2008 R2: code behind a blocking process
Labels:
MS SQL Server,
SQL Server 2005,
SQL Server 2008,
T-SQL,
Troubleshooting
Abonnieren
Kommentare zum Post (Atom)
Keine Kommentare:
Kommentar veröffentlichen