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