| description | SCHEMA_ID (Transact-SQL) | |||||
|---|---|---|---|---|---|---|
| title | SCHEMA_ID (Transact-SQL) | Microsoft Docs | |||||
| ms.custom | ||||||
| ms.date | 03/03/2017 | |||||
| ms.prod | sql | |||||
| ms.prod_service | database-engine, sql-database, sql-data-warehouse, pdw | |||||
| ms.reviewer | ||||||
| ms.technology | t-sql | |||||
| ms.topic | reference | |||||
| f1_keywords |
|
|||||
| dev_langs |
|
|||||
| helpviewer_keywords |
|
|||||
| ms.assetid | c8e34df5-3eea-459f-ae40-050909ce9fda | |||||
| author | julieMSFT | |||||
| ms.author | jrasnick | |||||
| monikerRange | >=aps-pdw-2016||=azuresqldb-current||=azure-sqldw-latest||>=sql-server-2016||>=sql-server-linux-2017||=azuresqldb-mi-current |
[!INCLUDE sql-asdb-asdbmi-asa-pdw]
Returns the schema ID associated with a schema name.
Transact-SQL Syntax Conventions
SCHEMA_ID ( [ schema_name ] )
[!INCLUDEsql-server-tsql-previous-offline-documentation]
| Term | Definition |
|---|---|
| schema_name | Is the name of the schema. schema_name is a sysname. If schema_name is not specified, SCHEMA_ID will return the ID of the default schema of the caller. |
int
NULL will be returned if schema_name is not a valid schema.
SCHEMA_ID will return IDs of system schemas and user-defined schemas. SCHEMA_ID can be called in a select list, in a WHERE clause, and anywhere an expression is allowed.
SELECT SCHEMA_ID(); SELECT SCHEMA_ID('dbo'); Metadata Functions (Transact-SQL)
SCHEMA_NAME (Transact-SQL)
sys.schemas (Transact-SQL)