-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathLockMonitor.sql
26 lines (22 loc) · 1.17 KB
/
LockMonitor.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
SELECT
request_session_id as session_id,
'DB' AS DatabaseName,
CASE WHEN o.name IS NULL THEN 'INDX Row' ELSE o.name END as table_name,
resource_associated_entity_id as table_id, request_mode, request_type, request_status,
request_owner_type, request_owner_id, resource_type, resource_subtype, resource_database_id
FROM sys.dm_tran_locks t LEFT OUTER JOIN .sys.sysobjects o ON
t.resource_associated_entity_id = o.id
where request_mode in ('X','IX') and resource_type in ('OBJECT')--, 'KEY')
and resource_database_id = DB_ID()
ORDER BY request_session_id, request_mode DESC
SELECT
request_session_id as session_id,
'DB' AS DatabaseName,
CASE WHEN o.name IS NULL THEN 'INDX Row' ELSE o.name END as table_name,
resource_associated_entity_id as table_id, request_mode, request_type, request_status,
request_owner_type, request_owner_id, resource_type, resource_subtype, resource_database_id
FROM sys.dm_tran_locks t LEFT OUTER JOIN sys.sysobjects o ON
t.resource_associated_entity_id = o.id
where request_mode in ('X','IX') and resource_type in ('OBJECT')--, 'KEY')
and resource_database_id = DB_ID()
ORDER BY request_session_id, request_mode DESC