My blog has moved to sqlblogcasts.com/blogs/simons
The full version of this post can be found here., http://sqlblogcasts.com/blogs/simons/object_name() to be extended in SP2
The new RSS feed is here
Kalen recently posted a suggestion that the object_name() function should take a database as well to resolve the name. This has bugged me for quite a while, generally when I've been looking at locks. The lock information resides in on table in master. and referenced the relevant DB of an object involved in a lock.
This meant that you have to either run the SQL specific to the database containing your objects, or join to that database's schema tables. Either way it was nasty and wasn't very flexible.
So the good news is that Kalen's suggestion is currently flagged for inclusion in SP2 and will enable you to provide a database Id and an object Id to get the object name.
This goes to show that connect does work, as can also be seen with the bugs I've raised recently against the Master Target server management in SSMS.
... To read the complete version of this post go here, http://sqlblogcasts.com/blogs/simons/object_name() to be extended in SP2