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 id | Schema id by name |
---|---|
1 | 1 |
See also: T-SQL Functions -> OBJECT_NAME | OBJECT_SCHEMA_NAME | SCHEMA_NAME