/ Published in: SQL
URL: http://www.microsoft.com/learning/en/us/book.aspx?ID=8565&locale=en-us
"LEFT JOIN sys.dmexecsessions SB" only for test... It is not necesary becouse in a real block condition "blockingsessionid" is not null. so, when you have tested it just replace Left with INNER JOIN sys.dmexecsess...
Good block detection to all!
Expand |
Embed | Plain Text
SELECT D.name , R.Session_ID , S.login_name , S.nt_user_name , R.Start_time , R.STATUS , R.Command , R.blocking_session_id , SB.login_name blocking_login_name , T.text FROM sys.dm_exec_requests R CROSS APPLY sys.dm_exec_sql_text(R.sql_handle) T INNER JOIN sys.DATABASES D ON R.database_id = D.database_id INNER JOIN sys.dm_exec_sessions S ON R.session_id = S.session_id LEFT JOIN sys.dm_exec_sessions SB ON R.blocking_session_id = SB.session_id WHERE R.sql_handle IS NOT NULL
You need to login to post a comment.
