T-SQL Tutorial

T-SQL Schema_Id() Metadata Function


The T-SQL Schema_Id() metadata function returns the schema id (int type) associated with a schema name.

Schema_Id() Syntax:

SCHEMA_ID()
SCHEMA_ID ( [ schema_name ] )

Schema_Id() Example:

SELECT SCHEMA_ID() AS 'Schema id',
SCHEMA_ID('dbo') AS 'Schema id by name';

Schema idSchema id by name
11

See also: T-SQL Functions -> OBJECT_NAME | OBJECT_SCHEMA_NAME | SCHEMA_NAME