SELECT
r.session_id,
r.status,
r.command,
r.start_time,
OBJECT_NAME(l.resource_associated_entity_id) AS table_name,
l.request_mode,
t.text AS query_text
FROM sys.dm_exec_requests r
LEFT JOIN sys.dm_tran_locks l
ON r.session_id = l.request_session_id
CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) t
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter