OBJECT ID OF AN OBJECT IN SQL SERVER 2005

We can use a function called Object_Id to find out the object id of the object.

Syntax is OBJECT_ID (‘ObjectName’)

The returns the database object identification number of a schema-scoped object.

Examples are given below.

1.SELECT OBJECT_ID ( ‘NewEmployee’ ) as ‘Object Identification Number’

OUTPUT
_________

Object Identification Number

749961748

2.It will return if the object is not there in the database.

SELECT OBJECT_ID ( ‘Employee’ ) as ‘Object Identification Number’

OUTPUT
_________

Object Identification Number

NULL — Returned NULL because the object new employee doesnot exists in the database.

3.One more way is there which is given below.

Select id as ‘Object Identification Number’ , [name] as ‘Object Name’ from sysobjects where name = ‘NewEmployee’

OUTPUT
_________

Object Identification Number Object Name
—————————- ————-
749961748 NewEmployee

Please let me know if you have any other way.

Pawan Kumar
Pawankkmr@hotmail.com