HiveBrain v1.2.0
Get Started
← Back to all entries
debugsqlCritical

The database principal owns a schema in the database, and cannot be dropped message

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
cannotthedroppedmessagedatabaseownsprincipalandschema

Problem

I am trying to delete a principal from the database but can't because it owns a schema. When I go to edit the user, however, the box to uncheck schemae is blue and unremovable. How can I remove the principal from these schemas?

Solution

Try the T-SQL to do this:

alter authorization
on schema::YourSchemaName
to dbo
go

drop user TheUserYouWantToDelete
go


You can't drop a principal that is a schema owner, so the ALTER AUTHORZATION changes the owned schema (I used YourSchemaName, but obviously substitute that with the owned schema in your database) to dbo (likewise, you can change ownership to whatever principal you need in your environment). That will allow you to drop the previously-schema-owning user (for example purposes I used TheUserYouWantToDelete, but that'll be the now non-owner that you want to drop).

Code Snippets

alter authorization
on schema::YourSchemaName
to dbo
go

drop user TheUserYouWantToDelete
go

Context

StackExchange Database Administrators Q#19456, answer score: 53

Revisions (0)

No revisions yet.