日期:2014-05-16  浏览次数:20572 次

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

 

 

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

 

 

3.删除用户test6

 

或者用下面的语句删除:

 

---查询用户test6拥有的Schemadb_owner

USE DBA;

 SELECT s.name

 FROM sys.schemas s

 WHERE s.principal_id= USER_ID('test6');

 

--db_owner SchemaOwner改为dbo

ALTER AUTHORIZATIONON SCHEMA::db_ownerTO dbo;

 

---再次查询用户test6拥有的Schema为空

 SELECT s.name

 FROM sys.schemas s

 WHERE s.principal_id= USER_ID('test6');

 

 --删除用户test6

 DROP USER [test6]