Query lock resources held by a session
Use adventureworksgoselect db_name (resource_database_id) as [database], resource_type -- database, file, object, page, key, extent, RID, application, metadata, HOBT, or allocation_unit --, resource_subtype, expires, case when resource_type = 'object' then (select object_name (object_id) from sys. objects O with (nolock) Where o. object_id = L. resource_associated_entity_id) When resource_type in ('key ', 'Page', 'rid', 'hobt ', 'metadata') Then (select object_name (object_id) from sys. partitions P with (nolock) Where p. hobt_id = L. end as resource_type_name, request_mode, REQUEST_TYPE, request_status, request_reference_count, request_session_id, request_request_id, request_owner_type -- transaction = the request is owned by the transaction. Cursor = the request is owned by the cursor. Session = the request is owned by the user session. -- Shared_transaction_workspace = the request is owned by the shared part of the transaction workspace. Exclusive_transaction_workspace = the request is owned by the exclusive part of the transaction workspace. -- Notification_object = the request is owned by the internal SQL server component. This component has requested the lock manager to notify when there are other components waiting to get the lock. The filetable function is a component that uses this value., Request_owner_id from SYS. dm_tran_locks as l with (nolock) Where request_session_id = 62View code