What does OBJECT_ID do in SQL Server?

I am trying to use OBJECT_ID and found the following entry in MSDN:

"Returns the identification number of the database object of the object with the scope of the schema.

What is the identification number of a database object and what is an object with a schema area. It seems I'm more embarrassed than the original.

+6
source share
1 answer

OBJECT_ID used to uniquely identify an object in the base tables of the system.

This is the sys.sysschobjs base table primary key used by the sys.objects metadata sys.objects and appears in many other metadata views. e.g. sys.partitions . If you do not request these representations, then OBJECT_ID not very useful, except, perhaps, when using the object to verify existence, as shown below.

 IF OBJECT_ID('T', 'U') IS NULL /*Table T does not exist or no permissions*/ 

An object with a schema area is an object that belongs to a schema (for example, a table, view, stored procedure). The MSDN article provides an example of an object with an unstructured scope in DDL triggers.

An error occurred while trying to specify the schema when creating these

 CREATE TRIGGER dbo.SomeTrigger /*Will Fail*/ ON DATABASE FOR DROP_SYNONYM AS PRINT 'SomeTrigger' 

Object metadata with restricted sys.sysschobjs areas is stored in sys.sysschobjs but not displayed in the sys.objects .

+4
source

Source: https://habr.com/ru/post/908947/


All Articles