The query below lists user schemas in Azure SQL Database, excluding the default db_* , sys, information_schema and guest schemas.
If you want to list all the schemas, use this script.
Query
select s.name as schema_name,
s.schema_id,
u.name as schema_owner
from sys.schemas s
inner join sys.sysusers u
on u.uid = s.principal_id
where u.issqluser = 1
and u.name not in ('sys', 'guest', 'INFORMATION_SCHEMA')
Columns
- schema_name - name of the schema
- schema_id - schema id, which is unique within the database
- schema_owner - principal that owns this schema
Rows
- One row: represents one schema in a database
- Scope of rows: all schemas in a database, excluding the default db_* , sys, information_schema and guest schemas
- Ordered by: schema name