Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. use AX2012_GRD_WORK
  2. select *
  3. --into desh.dbo.locks
  4. from (
  5. SELECT dm_tran_locks.request_session_id,
  6. dm_tran_locks.resource_database_id,
  7. DB_NAME(dm_tran_locks.resource_database_id) AS dbname,
  8. CASE
  9. WHEN resource_type = 'OBJECT'
  10. THEN OBJECT_NAME(dm_tran_locks.resource_associated_entity_id)
  11. ELSE OBJECT_NAME(partitions.OBJECT_ID)
  12. END AS ObjectName,
  13. partitions.index_id,
  14. indexes.name AS index_name,
  15. dm_tran_locks.resource_type,
  16. RTRIM(dm_tran_locks.resource_description) as resource_description,
  17. dm_tran_locks.resource_associated_entity_id,
  18. dm_tran_locks.request_mode,
  19. dm_tran_locks.request_status,
  20. dm_exec_sessions.host_name,
  21. dm_exec_sessions.host_process_id,
  22. cast(dm_exec_sessions.context_info as varchar(128)) as context_info
  23. FROM sys.dm_tran_locks
  24. LEFT JOIN sys.partitions ON partitions.hobt_id = dm_tran_locks.resource_associated_entity_id
  25. LEFT JOIN sys.indexes ON indexes.OBJECT_ID = partitions.OBJECT_ID AND indexes.index_id = partitions.index_id
  26. LEFT JOIN sys.dm_exec_sessions ON dm_exec_sessions.session_id = dm_tran_locks.request_session_id
  27. WHERE 1=1
  28. AND resource_associated_entity_id > 0
  29. AND resource_database_id = DB_ID()
  30. AND request_session_id in (618)
  31. ) T
  32. where 1=1
  33. --and objectname like N'REQCALCTASKSBUNDLE'
  34. --and index_name = 'I_417RECID'
  35. --and resource_type = 'KEY'
  36. --and request_mode = N'U'
  37. --and resource_description in (
  38. --select %%lockres%% from SPECTRANS WITH(NOLOCK INDEX(I_417RECID))
  39. --where SPECRECID = 22565455015)
  40. --and request_status = N'WAIT'
  41. ORDER BY request_session_id, ObjectName, index_name, resource_description
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement