Skip to content

Instantly share code, notes, and snippets.

@kshimi
Created March 14, 2019 09:55
Show Gist options
  • Save kshimi/44f1943e2ad74053683a5ad9094bb5a1 to your computer and use it in GitHub Desktop.
Save kshimi/44f1943e2ad74053683a5ad9094bb5a1 to your computer and use it in GitHub Desktop.
SQLServer check lock status
SELECT
resource_type AS type
,resource_associated_entity_id as entity_id
,( CASE WHEN resource_type = 'OBJECT' THEN
OBJECT_NAME( resource_associated_entity_id )
ELSE
( SELECT
OBJECT_NAME( OBJECT_ID )
FROM
sys.partitions
WHERE
hobt_id=resource_associated_entity_id )
END)
AS object_name
,request_mode AS request_mode
,request_type AS request_type
,request_status AS request_status
,request_session_id AS session_id
FROM
sys.dm_tran_locks
WHERE
resource_type <> 'DATABASE'
ORDER BY
request_session_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment