Appreciate your help. It took a lot of digging to find what you already knew!
I was able to find the spid and from it the sqlhandle which is supposed to contain the actual query text. Nothing I could see gave me the table name or row number locked (see long query). I assumed from the sqlhandle text I could parse the table or row being used. As you recall, I am trying to get info on locks created by closed/proprietary application.
Instead when I enter the sqlhandle into the query below,
Code: Select all
SELECT * FROM
sys.dm_exec_sql_text(0x010009007A116D21781E15040000000000000000)
it simply returns fetch api_cursor....
Here is the large query I used to find the sql handle for the spid. I cannot find any columns in all the datatables in this query that actually refer to the table and row locked. That is why I pulled the sqlhandle and looked for the query text associated with it.
Code: Select all
SELECT DISTINCT
SP.spid, SP.hostname, SP.program_name, SP.loginame,
(CASE A.REQUEST_MODE WHEN 'SCH-S' THEN 'SCHEMA STABILITY' WHEN 'SCH-M' THEN 'SCHEMA MODIFICATION' WHEN 'S' THEN 'SHARED' WHEN
'U' THEN 'UPDATE' WHEN 'X' THEN 'EXCLUSIVE' WHEN 'IS' THEN 'Intent Shared' WHEN 'IU' THEN 'Intent Update' WHEN 'IX' THEN 'Intent Exclusive' WHEN
'SIU' THEN 'Shared Intent Update' WHEN 'SIX' THEN 'Shared Intent Exclusive' WHEN 'UIX' THEN 'Update Intent Exclusive' WHEN 'BU' THEN 'Bulk Update'
WHEN 'RangeS_S' THEN 'Shared Key-Range and Shared Resourcelock' WHEN 'RangeS_U' THEN 'Shared Key-Range and Update Resource lock' WHEN
'RangeI_N' THEN 'Insert Key-Range and Null Resourcelock' WHEN 'RangeI_S' THEN 'Key-Range Conversion lock, created by an overlap of RangeI_N and S locks'
WHEN 'RangeI_U' THEN 'Key-Range Conversion lock, created byan overlap of RangeI_N and U locks' WHEN 'RangeI_X' THEN 'Key-Range Conversion lock, created byan overlap of RangeI_N and X locks'
WHEN 'RangeX_S' THEN 'Key-Range Conversion lock, created byan overlap of RangeI_N and RangeS_S locks' WHEN 'RangeX_U' THEN 'Key-Range Conversion lock, created byan overlap of RangeI_N and RangeS_U locks'
WHEN 'RangeX_X' THEN 'Exclusive Key-Range and ExclusiveResource lock' ELSE NULL END) AS REQUEST_LOCK_MODE, DB_NAME(SP.dbid)
AS DATABASE_NAME, SP.sql_handle
FROM sys.dm_tran_locks AS A INNER JOIN
sys.sysprocesses AS SP ON A.request_session_id = SP.spid LEFT OUTER JOIN
sys.dm_exec_requests AS B ON A.request_request_id = B.request_id LEFT OUTER JOIN
sys.dm_tran_active_transactions AS C ON A.request_owner_id = C.transaction_id
WHERE (SP.spid > 50) AND (SP.program_name NOT LIKE 'SQLAGENT%') AND
((CASE A.REQUEST_MODE WHEN 'SCH-S' THEN 'SCHEMA STABILITY' WHEN 'SCH-M' THEN 'SCHEMA MODIFICATION' WHEN 'S' THEN 'SHARED' WHEN
'U' THEN 'UPDATE' WHEN 'X' THEN 'EXCLUSIVE' WHEN 'IS' THEN 'Intent Shared' WHEN 'IU' THEN 'Intent Update' WHEN 'IX' THEN 'Intent Exclusive' WHEN
'SIU' THEN 'Shared Intent Update' WHEN 'SIX' THEN 'Shared Intent Exclusive' WHEN 'UIX' THEN 'Update Intent Exclusive' WHEN 'BU' THEN 'Bulk Update'
WHEN 'RangeS_S' THEN 'Shared Key-Range and Shared Resourcelock' WHEN 'RangeS_U' THEN 'Shared Key-Range and Update Resource lock' WHEN
'RangeI_N' THEN 'Insert Key-Range and Null Resourcelock' WHEN 'RangeI_S' THEN 'Key-Range Conversion lock, created by an overlap of RangeI_N and S locks'
WHEN 'RangeI_U' THEN 'Key-Range Conversion lock, created byan overlap of RangeI_N and U locks' WHEN 'RangeI_X' THEN 'Key-Range Conversion lock, created byan overlap of RangeI_N and X locks'
WHEN 'RangeX_S' THEN 'Key-Range Conversion lock, created byan overlap of RangeI_N and RangeS_S locks' WHEN 'RangeX_U' THEN 'Key-Range Conversion lock, created byan overlap of RangeI_N and RangeS_U locks'
WHEN 'RangeX_X' THEN 'Exclusive Key-Range and ExclusiveResource lock' ELSE NULL END) = 'UPDATE')
ORDER BY SP.spid