Returns the database object identification number.
OBJECT_ID('object')
int
When the parameter to a system function is optional, the current database, host computer, server user, or database user is assumed. Built-in functions must always be followed by parentheses.
Important When specifying a temporary table name, the database name must precede the temporary table name, for example:
SELECT OBJECT_ID('tempdb..#mytemptable')
System functions can be used in the select list, in the WHERE clause, and anywhere an expression is allowed. For more information, see Expressions and WHERE.
This example returns the object ID for the authors table in the pubs database.
USE master
SELECT OBJECT_ID('pubs..authors')
Here is the result set:
-----------
117575457
(1 row(s) affected)