SCHEMA_ID and SCHEMA_NAME functions
Posted by: SQL Server 2005 Distilled,
on 20 Nov 2005 |
View original | Bookmarked: 0 time(s)
SCHEMA_ID can be used to find out the schema id associated with a schema name, while the SCHEMA_NAME function returns the schema name associated with the specified schema id. If no parameter is passed, the functions return caller's default schema id/name. Try out the following:
SELECT SCHEMA_ID();
SELECT SCHEMA_NAME();
SELECT SCHEMA_ID('sys');
SELECT SCHEMA_NAME(4);
Here is another example of a script that uses SCHEMA_ID function. The following three SELECT statements use the sys.system_views...