ERROR:
“The database principal owns a schema in the database, and cannot be dropped. (Microsoft SQL Server, Error: 15138)”
EXPLANATION:
You may encounter an error message when you try to delete a database user.
SOLUTION:
Before deleting a database user, you must delete the schema that this user owns.
You can access the schema from SSMS by:
Object Explorer -> Server Name-> Databases -> Your_Database-> Security -> Schemas
With TSQL:
1 2 3 4 5 |
USE database_name GO SELECT dp.name [Database User], s.name [Schema Name] FROM sys.schemas s INNER JOIN sys.database_principals dp ON s.principal_id = dp.principal_id WHERE dp.name = 'EKREM-PC\EKREM' |