Hi,

When you are trying to remove user from a database, you will get:

The database principal owns a schema in the database, and cannot be dropped. (Microsoft SQL Server, Error: 15138)

There is a easy fix for this.

First see what Schemas the user principal own's:

USE DATABASENAME;
SELECT s.name
FROM sys.schemas s

WHERE s.principal_id = USER_ID('domainusername');

Then use that database to the following query:

ALTER AUTHORIZATION ON SCHEMA::db_owner TO db_owner;

Now you can delete the user and add it again.

Archives