Symptom: You receive the following error when trying to drop an orphaned user from a msSQL database.
The database principal owns a schema in the database, and cannot be dropped. (Microsoft SQL Server, Error: 15421)
Solution: Follow the steps below:
- Open up Microsoft SQL Server Management Studio
- Start->All Programs->Microsoft SQL Server 2008 R2->SQL Server Management Studio
- Navigate to the database that you cannot drop the user from.
- Expand the Security section inside of the database
- Expand the Users section and right click on the user and rename it (to something other than the new user... assuming you are trying to use a new login with the same username)
- Expand the Roles section underneeth the Security section
- Expand the Database Roles section
- For each Database Role, Right click->Properties on a role and ensure the Owner attribute is set to the new account you wish to use
- Once you have removed all references to the orphaned account inside of the Owner attributes, you should be able to remove the user from the database.