Drop Failed For User (Microsoft.SQLServer.SMO) – Database Principal Owns A Schema

When trying to delete a user from a database in MSSQL, you can get the following error:

Microsoft SQL Server Management Studio

Drop failed for User <<SQL User>>. (Microsoft.SqlServer.Smo)

Additional information:

An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)

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

This is because the user account you are trying to delete is a dbo schema owner. Each database in SQL must have a user account that is marked as the schema owner, so to delete / drop the user account that is the schema owner, you must first change the schema owner for the database. To do this:

  1. Open a connection to the SQL Server in Microsoft SQL Server Management Studio
  2. Navigate to the database that the user you want to drop is a schema owner of
  3. Navigate to Security -> Users
  4. Right click a user to be the new schema owner
  5. Click Properties
  6. Click Owned Schemas
  7. Check the db_owner box
  8. Click OK

The database schema owner is now changed and you will be able to drop the user account without error 15138.

VN:F [1.9.22_1171]
Rating: 8.0/10 (1 vote cast)
Drop Failed For User (Microsoft.SQLServer.SMO) - Database Principal Owns A Schema, 8.0 out of 10 based on 1 rating

Leave a comment

Your email address will not be published. Required fields are marked *