删除用户报错:
Msg 15138, Level16, State 1, Line 1
The database principal owns a schemain the database, and cannot be dropped.
解决办法(SSMS):
1.找到用户拥有的Schema
2.在Schema中找到db_owner将Schema Owner由test6改为dbo或者其他用户
3.删除用户test6
或者用下面的语句删除:
---查询用户test6拥有的Schema为db_owner
USE DBA;
SELECT s.name
FROM sys.schemas s
WHERE s.principal_id=USER_ID('test6');
--将db_owner Schema的Owner改为dbo
ALTER AUTHORIZATIONONSCHEMA::db_ownerTO dbo;
---再次查询用户test6拥有的Schema为空
SELECT s.name
FROM sys.schemas s
WHERE s.principal_id=USER_ID('test6');
--删除用户test6
DROP USER [test6]
本文转自 lzf328 51CTO博客,原文链接:
http://blog.51cto.com/lzf328/1044837