How can I convert a key in a SQL Server deadlock report to the value? I have a deadlock report that tells me that there was a conflict involving
waitresource=&quot;KEY: 9:72057632651542528 (543066506c7c)&quot;

and I can see this:
&lt;keylock hobtid=&quot;72057632651542528&quot; dbid=&quot;9&quot; objectname=&quot;MyDatabase.MySchema.MyTable&quot; indexname=&quot;MyPrimaryKeyIndex&quot; id=&quot;locka8c6f4100&quot; mode=&quot;X&quot; associatedObjectId=&quot;72057632651542528&quot;&gt;

within the &lt;resource-list&gt; element.
I want to be able to find the actual value for the key (id = 12345, for example). What SQL statement would I need to use to obtain that information?
You have the hobt_id so the following query will identify the table:-

SELECT o.name
FROM sys.partitions p
INNER JOIN sys.objects o ON p.object_id = o.object_id
WHERE p.hobt_id = 72057632651542528


From that you can then run the following statement to identify the row in the table (if it still exists):-

SELECT %%LOCKRES%%,  *
FROM [TABLE NAME] WITH(INDEX(MyPrimaryKeyIndex))
WHERE %%LOCKRES%% = '(543066506c7c)'


Be careful with the above statement however, it will scan the target table so run in READ UNCOMMITTED and monitor your server.

Here's an article by Grant Fritchey about %%LOCKRES%% - http://www.scarydba.com/2010/03/18/undocumented-virtual-column-lockres/

And here's an article from my own blog about using %%LOCKRES%% to identify rows from an extended event:-  https://dbafromthecold.wordpress.com/2015/02/24/identifying-blocking-via-extended-events/