sql server lock detection

Solutions on MaxInterview for sql server lock detection by the best coders in the world

showing results for - "sql server lock detection"
Leana
07 Jan 2017
1SELECT
2db.name DBName,
3tl.request_session_id,
4wt.blocking_session_id,
5OBJECT_NAME(p.OBJECT_ID) BlockedObjectName,
6tl.resource_type,
7h1.TEXT AS RequestingText,
8h2.TEXT AS BlockingTest,
9tl.request_mode
10FROM sys.dm_tran_locks AS tl
11INNER JOIN sys.databases db ON db.database_id = tl.resource_database_id
12INNER JOIN sys.dm_os_waiting_tasks AS wt ON tl.lock_owner_address = wt.resource_address
13INNER JOIN sys.partitions AS p ON p.hobt_id = tl.resource_associated_entity_id
14INNER JOIN sys.dm_exec_connections ec1 ON ec1.session_id = tl.request_session_id
15INNER JOIN sys.dm_exec_connections ec2 ON ec2.session_id = wt.blocking_session_id
16CROSS APPLY sys.dm_exec_sql_text(ec1.most_recent_sql_handle) AS h1
17CROSS APPLY sys.dm_exec_sql_text(ec2.most_recent_sql_handle) AS h2
18GO