Drop User: The database principal owns a schema in the database, and cannot be dropped

by Allan Svelmøe Hansen February 05, 2009 18:57

Dropping a user which owns a schema will result in the error message “The database principal owns a schema in the database, and cannot be dropped”.

To solve this you can assign the schema back to its base principal with the ALTER AUTHORIZATION message, or it can be moved to another user/principal.
If for example user Test1 owns the db_owner schema and you want to drop Test1 but don’t have another user to move the schema to you can type:

ALTER AUTHORIZATION ON SCHEMA::db_owner TO db_owner  
(or for example db_datawriter if that was the case and so on)

If you wanted to move the schema to another user the syntax would be:

ALTER AUTHORIZATION ON SCHEMA::<theSchemaTO userName  

Bookmark and Share DotnetKicks dotnetshoutout

Powered by BlogEngine.NET 1.6.1.0
Theme by Mads Kristensen | Modified by Mooglegiant

About:
Allan Svelmøe Hansen

My real name is Allan Svelmøe Hansen.
I live in Denmark, where I work as a developer for hedal:kruse:brohus using SQL Server and the .NET framework since 2004.
My primary fields of expertise is back-end data integration, database design and optimization.


       View Allan Svelmøe Hansen's profile on LinkedIn     

Disclaimer

The opinions expressed herein are my own personal opinions and thoughts and does not represent my employers view in any way, nor are my results guaranteed for all situations.
Content is presented "as is", with no warranty.