owns a schema in the database, and cannot be dropped

USE test;
SELECT s.name
FROM sys.schemas s
WHERE s.principal_id = USER_ID('manoj');


In our case we have two schema so we will execute it two times


ALTER AUTHORIZATION ON SCHEMA::db_denydatareader TO dbo;
ALTER AUTHORIZATION ON SCHEMA::db_denydatawriter TO dbo;


Now if you drop the database, it will not throw any error.

Here is generic script for resolving the error:


SELECT s.name
FROM sys.schemas s
WHERE s.principal_id = USER_ID('YourUserID');

Now replace the result name in following script:



ALTER AUTHORIZATION ON SCHEMA::YourSchemaName TO dbo;
Ebook Download
View all
Learn
View all