Query below lists user schemas in SQL Server database, excluding default db_* , sys, information_schema and guest schemas.
If you want to list all 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 - schema name
- schema_id - schema id, 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 default db_* , sys, information_schema and guest schemas
- Ordered by schema name