Monday, July 31, 2023

How to drop a SQL Server user with db owner privilege

The error


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


Query to identify users:

SELECT s.name

FROM sys.schemas s

WHERE s.principal_id = USER_ID('user');


Query Executed
ALTER AUTHORIZATION ON SCHEMA::db_owner TO dbo;
ALTER AUTHORIZATION ON SCHEMA::db_datareader TO dbo;
ALTER AUTHORIZATION ON SCHEMA::db_datawriter TO dbo;

finally

drop user usertobeDeleted

based https://stackoverflow.com/questions/35434389/how-to-drop-a-sql-server-user-with-db-owner-privilege 

No comments:

Post a Comment