// SQL Server error reference

SQL Server error 15138: User owns a schema, cannot be dropped

DROP USER failed because the user owns a schema (or other securable). Transfer ownership to another principal first, then drop the user.

Error number
15138
Severity
16
Category
Permissions
Error message
The database principal owns a %S_MSG in the database, and cannot be dropped.

What it means

A database user that owns a schema, role or other securable can't be dropped, because the object would be left without an owner. The message names the kind of object owned (for example owns a schema in the database).

Common causes

  • The user owns a schema, often a schema with the same name created automatically for it.
  • The user owns a database role or another securable.

How to fix it

  1. Find what the user owns.

    SELECT s.name AS schema_name FROM sys.schemas AS s WHERE s.principal_id = USER_ID(N'old_user');
    SELECT r.name AS role_name FROM sys.database_principals AS r WHERE r.owning_principal_id = USER_ID(N'old_user');
  2. Transfer ownership, then drop the user.

    ALTER AUTHORIZATION ON SCHEMA::old_user TO dbo;
    DROP USER old_user;

Related errors

More permissions errors

The code and message text are from the Microsoft Database Engine events and errors reference. Browse the full SQL Server error list or search every database error.

// fewer errors, faster fixes

Work on SQL Server in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for SQL Server and the other databases you use.