Skip to content
Microsoft SQL Server

SQL Server Error 15138

The database principal owns a schema and cannot be dropped

Severity 16 Logins & Permissions
Applies to: All supported SQL Server versions (2016 to 2025), Azure SQL Database, Azure SQL Managed Instance
Last technically reviewed 24 October 2026 on SQL Server 2025 (17.0.1145.4)
The full message
Msg 15138, Level 16, State 1, Line 1
The database principal owns a schema in the database, and cannot be dropped.
Other forms of this message
Related check, different number: DROP USER of a user that owns a database role (reproduced)
Msg 15421, Level 16, State 1, Line 1
The database principal owns a database role and cannot be dropped.
Error number
15138
Severity
16 (user-correctable error)
State
1
Product
Microsoft SQL Server Database Engine
Versions
All supported SQL Server versions (2016 to 2025), Azure SQL Database, Azure SQL Managed Instance
Last reviewed
24 October 2026

What it means

Error 15138 means DROP USER or DROP ROLE was refused because that user or role is still the owner of a schema in the database; transfer the schema to another owner first.

Every schema has exactly one owner, a database principal (a user or a role). SQL Server will not leave a schema without an owner, so DROP USER and DROP ROLE check sys.schemas first and stop with 15138 at severity 16 if the principal owns any schema. Nothing is dropped. The message does not name the schema, so you have to look it up.

The typical story: a user was created for a person or an application, and CREATE SCHEMA ... AUTHORIZATION (or the SQL Server Management Studio user dialog, Owned Schemas page) made it the owner. Months later the person leaves and the drop fails. The objects inside the schema are not the problem; ownership of the schema is. A related check exists for roles owned by a user: that case raises error 15421 (owns a database role) instead.

Common causes

  • The user was given ownership of a schema with CREATE SCHEMA name AUTHORIZATION user or on the Owned Schemas page of the user properties.
  • A schema with the same name as the user was created by a script or tool that gives every user its own schema, so the user owns "its" schema.
  • A database role being dropped owns a schema (role-owned schemas are common in shared reporting databases).
  • A cleanup script drops users in a loop without transferring their schemas first.

Diagnose it

Read-only These queries only read metadata and dynamic management views. They do not change data, permissions or configuration, so they are safe to run first.

Which schemas does the principal own?

Run in the database where the drop failed. Replace the name with the user or role you tried to drop.

SELECT s.name AS schema_name, dp.name AS owner_name, dp.type_desc
FROM sys.schemas AS s
JOIN sys.database_principals AS dp ON dp.principal_id = s.principal_id
WHERE dp.name = N'report_owner';
What to look for

Each row is a schema that blocks the drop. Transfer every one of them (fix 1).

How many objects live in those schemas?

SELECT s.name AS schema_name, COUNT(o.object_id) AS objects
FROM sys.schemas AS s
JOIN sys.database_principals AS dp ON dp.principal_id = s.principal_id
LEFT JOIN sys.objects AS o ON o.schema_id = s.schema_id
WHERE dp.name = N'report_owner'
GROUP BY s.name;
What to look for

Zero objects means the schema is probably unused and could be dropped instead of transferred. Any objects mean the schema is in use: keep it and change its owner.

Does the principal also own database roles?

SELECT r.name AS role_name, o.name AS owner_name
FROM sys.database_principals AS r
JOIN sys.database_principals AS o ON o.principal_id = r.owning_principal_id
WHERE r.type = 'R'
  AND o.name = N'report_owner';
What to look for

Rows here will block the drop with error 15421 once the schemas are fixed. Change those owners too.

How to fix it

Each fix is labelled with what it changes. Try read-only checks and the least invasive fix first, and test changes outside production.

Transfer the schema to another owner, then drop the user

Changes permissions

Give the schema to dbo or to a role that represents the team, then repeat the drop. The objects stay where they are; only the owner changes. If the old owner was chosen on purpose (for example to control ownership chaining between schemas), pick a new owner that keeps the same chain, and review the permissions on the schema afterwards.

ALTER AUTHORIZATION ON SCHEMA::reporting TO dbo;

DROP USER report_owner;

Drop the schema if it is empty and no longer needed

Changes schema

If the diagnostic shows no objects in the schema, dropping the schema is cleaner than keeping an empty one. DROP SCHEMA fails if any object remains in it.

DROP SCHEMA reporting;

DROP USER report_owner;

Generate the transfers for every owned schema

Read-only

For a principal that owns many schemas, this query only generates the statements. Review the output, then run it as a separate step (that step changes permissions).

SELECT N'ALTER AUTHORIZATION ON SCHEMA::' + QUOTENAME(s.name) + N' TO dbo;'
FROM sys.schemas AS s
JOIN sys.database_principals AS dp ON dp.principal_id = s.principal_id
WHERE dp.name = N'report_owner';

Examples

Dropping a user that owns a schema

CREATE USER report_owner WITHOUT LOGIN;
GO
CREATE SCHEMA reporting AUTHORIZATION report_owner;
GO
DROP USER report_owner;
Result
Msg 15138, Level 16, State 1, Line 1
The database principal owns a schema in the database, and cannot be dropped.

Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.

Dropping a role that owns a schema

CREATE ROLE etl_role;
GO
CREATE SCHEMA staging AUTHORIZATION etl_role;
GO
DROP ROLE etl_role;
Result
Msg 15138, Level 16, State 1, Line 1
The database principal owns a schema in the database, and cannot be dropped.

Reproduced on SQL Server 2025 (17.0.1145.4), 23 October 2026.

How to prevent it

Let schemas be owned by dbo or by a role, never by an individual person's user, and grant people permissions on the schema instead of ownership. Ownership by a role survives staff changes; ownership by a person turns every leaver into a 15138.

Make user removal a small script that first lists and transfers owned schemas and roles, then drops the user. The SQL Server security lesson covers how users, roles and schemas fit together.

Common questions

Does changing the schema owner move or delete the tables?

No. ALTER AUTHORIZATION only changes who owns the schema. The tables, views and procedures keep their names (reporting.SomeTable stays reporting.SomeTable) and their data.

Which schema does the user own? The message does not say.

Query sys.schemas joined to sys.database_principals on principal_id for the user name. In SQL Server Management Studio, the Owned Schemas page of the user properties shows the same list.

Is a user's default schema the same as a schema it owns?

No. The default schema only decides where unqualified names are resolved and created. It does not block DROP USER; ownership does.

Learn more on CodeWithSQL

Official documentation

Last technically reviewed 24 October 2026; examples and diagnostics run on SQL Server 2025 (17.0.1145.4). Message text checked against the engine's sys.messages catalogue.

Still stuck on a SQL Server error?

Browse the full SQL Server error library, or get hands-on help from an experienced SQL professional.