Wednesday, 19 February 2014

The database principal owns a database role and cannot be dropped.

SQL Command:
DROP USER [User_NAME]

Error Message:
The database principal owns a database role and cannot be dropped.

Solution:
SELECT T2.Name, T1.Name
FROM sys.database_principals AS T1 JOIN sys.database_principals AS T2 ON T1.owning_principal_id = T2.principal_id
 WHERE T1.type = 'R' AND T2.name = 'USER_NAME'

Output:
Database roles from which to remove this user before re-trying the deletion.

No comments:

Post a Comment