Object_ID and Object_Name functions – SQL Server
Object_id() and Object_name() functions are used to get the schema-scoped object’s Identification number and Name.
Object_id(): This function is used to get the schema-scoped object identification number in a database object. this function returns an integer value.
OBJECT_ID ( object_name, [object_type ] )
We can provide object name with database name and schema name. For instance, TestDb.dbo.Object_name or dbo.Object_name. Object type parameter is also an optional value. But, if you want to use this value then you can use the information given in below image.
Object_name: This function gives the object name for schema-scoped objects in a database. It returns a sysname (
nvarchar(128) NOT NULL) type output.
OBJECT_NAME ( object_id [, database_id ] )
We have to provide the object identification number to this function to get the object name. Database identification number is an optional parameter.
1. Get object name
We can use these catalog views to fetch the object information with more details
1) List user-defined, schema-scoped objects
Select * from sys.objects
2) List of all schema-scoped system objects
select * from sys.system_objects
3) UNION of all schema-scoped user-defined objects and system objects.
select * from sys.all_objects