SCHEMA_ID (TSQL Function)
Returns the ID of the schema in the current database.
Syntax
SCHEMA_ID ( [schema_name] )
Arguments
- ‘schema_name’
- optional argument, of type
varchar
. If omitted, the ID of the current schema is returned.
Return Types
Returns bigint
.
Remarks
Returns NULL if the schema doesn’t exist in the current database.
Examples
PRINT SCHEMA_ID();
PRINT SCHEMA_ID('dbo');
PRINT SCHEMA_ID('non_existent_schema');
The result is:
0
0
<NULL>