sql >> Database teknologi >  >> RDS >> Sqlserver

Sådan finder du ud af, hvilken tabel en sidelås tilhører

Dette er hvad resource_associated_entity_id kolonne er for (Eksempel på forespørgsel ).

SELECT dm_tran_locks.request_session_id,
       dm_tran_locks.resource_database_id,
       DB_NAME(dm_tran_locks.resource_database_id) AS dbname,
       CASE
           WHEN resource_type = 'OBJECT'
               THEN OBJECT_NAME(dm_tran_locks.resource_associated_entity_id)
           ELSE OBJECT_NAME(partitions.OBJECT_ID)
       END AS ObjectName,
       partitions.index_id,
       indexes.name AS index_name,
       dm_tran_locks.resource_type,
       dm_tran_locks.resource_description,
       dm_tran_locks.resource_associated_entity_id,
       dm_tran_locks.request_mode,
       dm_tran_locks.request_status
FROM sys.dm_tran_locks
LEFT JOIN sys.partitions ON partitions.hobt_id = dm_tran_locks.resource_associated_entity_id
LEFT JOIN sys.indexes ON indexes.OBJECT_ID = partitions.OBJECT_ID AND indexes.index_id = partitions.index_id
WHERE resource_associated_entity_id > 0
  AND resource_database_id = DB_ID()
ORDER BY request_session_id, resource_associated_entity_id 


  1. Sikkerhedskopier en mysql-database og download som en fil

  2. Kan ikke aggregere arrays

  3. Hvad er forskellen mellem int og heltal i MySQL 5.0?

  4. Oracle (0x80004005)ORA-12154:TNS:kunne ikke løse forbindelses-id'et