T-SQL Tutorial

T-SQL OBJECT_ID() metadata function


The OBJECT_ID() metadata function returns the database object id number of a schema object.
The objects can be tables, views, constraints.
The value returned by the object_id() function is stored in the system view sys.all_objects, in the column object_id.

Object_Id() Syntax:

OBJECT_ID ( 'database_name . schema_name . object_name' )

Object_Id() Example:

SELECT OBJECT_ID('model.dbo.products') AS 'Object ID of Table',
OBJECT_ID('master.dbo.products_list') AS 'Object ID of View';

Object ID of TableObject ID of View
245575913279672044

See also: T-SQL Functions -> APP_NAME | DB_ID | DB_NAME | OBJECT_DEFINITION