This blog post explains the issue that we usually face while dropping the users from the database and how can we resolve the issue.
We can create a user for database easily by any of the following user types,
If we want to drop the user then we can write drop statement but it will throw a below error in case the user owned any of the schemas.
Msg 15138, Level 16, State 1, Line 20
The database principal owns a schema in the database, and cannot be dropped.
To resolve the issue, Follow the below steps.
Step 1: Check the schema that owned by the user.
FROM sys.schemas s
WHERE s.principal_id = USER_ID(‘Username’)
Step 2: Change the schema back to dbo.
ALTER AUTHORIZATION ON SCHEMA::<schemaname> TO dbo;
Step 3: Drop the user
DROP USER <username>