Ward Pond's SQL Server blog

Ruminating on issues pertinent to the design and development of sound databases and processes under Microsoft SQL Server 2008, SQL Server 2005, and SQL Server 2000 (while reserving the right to vent about anything else that's on my mind)

Database Programming: OBJECT_ID Takes Three-Part Identifiers

Database Programming: OBJECT_ID Takes Three-Part Identifiers

  • Comments 2
  • Likes

This is another one of those tricks that’s been available since the earth was cooling, but I just discovered it recently.

So, here’s a history lesson in the form of a small T-SQL script, with the moral contained in the title of this post:

set nocount on
use master
select  object_id('sysobjects') as ObjectIdFromMaster

use tempdb

select  object_id('master.dbo.sysobjects') as ObjectIdFromTempdb

select  id as ObjectIdFromCatalogView
from    master.dbo.sysobjects
where   name = 'sysobjects'

All three SELECT statements return the same result, proving that the OBJECT_ID function will indeed properly process a three-part name:




This works all the way back to SQL Server 2000, which is the oldest platform I’ve got conveniently available.

Thanks to my colleague Venkata Raj Pochiraju for showing me this classic.


  • programming a lot of information and knowledge the programmer need logic and experience to create an application or project,


  • This post is a cousin of sorts to last December’s post regarding the OBJECT_ID function. I learned this

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment