Export (0) Print
Expand All
Expand Minimize
1 out of 1 rated this helpful - Rate this topic

SCHEMA_ID (Transact-SQL)

Returns the schema ID associated with a schema name.

Topic link icon Transact-SQL Syntax Conventions


SCHEMA_ID( [ schema_name ] ) 

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.

A. Returning the default schema ID of a caller

select schema_id();
GO

B. Returning the schema ID of a named schema

USE AdventureWorks;
GO
SELECT SCHEMA_ID('HumanResources');
GO 
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.