When using SQL Server, if you ever find yourself about to do a join against the sys.objects
system catalog view in order to get the name of an object, maybe stop and read this first.
Transact-SQL has a built-in function called OBJECT_NAME()
that returns the name of an object, based on its ID.
In other words, if you have the object’s ID (for example, the object_id
column), you can simply pass that ID to the OBJECT_NAME()
function, and it will return the object’s name for you – no join required!