读书人

Msg 15138 The database principal ow

发布时间: 2012-11-10 10:48:51 作者: rapoo

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

删除用户报错:

Msg 15138, Level16, State 1, Line 1

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

解决办法(SSMS):

1.找到用户拥有的Schema

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

2.在Schema中找到db_owner将Schema Owner由test6改为dbo或者其他用户

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

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]

读书人网 >其他数据库

热点推荐