SQL Server – Resolving Object ID Errors

error handlingsql serversql-server-2012system-tablest-sql

I want to know the object referenced as an associatedObjectId in a deadlock graph, so I ran the below query:

SELECT OBJECT_NAME(1234560112364076) 

I get the following error:

Arithmetic overflow error converting expression to data type int.

Best Answer

That looks more like a hobt_id than an object_id. Try:

SELECT [schema] = s.name, [table] = o.name, [index] = i.name
FROM sys.schemas AS s
INNER JOIN sys.objects AS o
ON s.[schema_id] = o.[schema_id]
INNER JOIN sys.partitions AS p
ON p.[object_id] = o.[object_id]
INNER JOIN sys.indexes AS i
ON i.index_id = p.index_id
AND i.[object_id] = p.[object_id]
WHERE p.hobt_id = 1234560112364076
GROUP BY s.name, o.name, i.name;

Also, I recommend opening the .xdl in SentryOne Plan Explorer, which should present you with friendly object names instead of long, indecipherable ids. I explain the deadlock analysis functionality here.