Description of the problem: When you tried to drop a user, you got this message:

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

Cause: That means, you are trying to drop a user owning a schema. In order to drop the user, you have to find the schema that’s assigned and then transfer the ownership to another user/role or to drop it.

Resolution:


You can fix the issue following two ways.

By script: You can find out which schema is owned by this user with the query below:

SELECT name FROM  sys.schemas WHERE principal_id = USER_ID('myUser')

Then, use the names found from the above query below in place of the SchemaName below. And drop your user.

ALTER AUTHORIZATION ON SCHEMA::SchemaName TO dbo
GO
DROP USER myUser

By Management Studio:

- Object Explorer >> Expand the [databasename] >> Security.
- Click on Schemas.
- In summary window, determine which Schema(s) are owned by the user and either change the owner or remove the Scheme(s).
- If they are system schema(s), I suggest to change them to ‘dbo’.
- Drop your user.

More detail about schemas into the BOL:

User-Schema Separation

原文链接

SQL Server中删除用户时报错,提示:The database principal owns a schema in the database, and cannot be dropped(转载)的更多相关文章

  1. SQL Server中查询用户的对象权限和角色的方法

    --SQL Server中查询用户的对象权限和角色的方法 -- 查询用户的object权限 exec sp_helprotect NULL, 'sa' -- 查询用户拥有的role exec sp_h ...

  2. SQL Server中授予用户查看对象定义的权限

    SQL Server中授予用户查看对象定义的权限   在SQL Server中,有时候需要给一些登录名(用户)授予查看所有或部分对象(存储过程.函数.视图.表)的定义权限存.如果是部分存储过程.函数. ...

  3. 转 在SQL Server中创建用户角色及授权(使用SQL语句)

     目录 要想成功访问 SQL Server 数据库中的数据 我们需要两个方面的授权 完整的代码示例 使用存储过程来完成用户创建 实例 要想成功访问 SQL Server 数据库中的数据, 我们需要两个 ...

  4. 在SQL Server中创建用户角色及授权

    参考文献 http://database.51cto.com/art/201009/224075.htm 正文 要想成功访问 SQL Server 数据库中的数据, 我们需要两个方面的授权: 获得准许 ...

  5. 【转】在SQL Server中创建用户角色及授权(使用SQL语句)

    1. 首先在 SQL Server 服务器级别,创建登陆帐户(create login) --创建登陆帐户(create login) create login dba with password=' ...

  6. 在SQL Server中创建用户角色及授权(使用SQL语句)

    1. 首先在 SQL Server 服务器级别,创建登陆帐户(create login) --创建登陆帐户(create login) create login dba with password=' ...

  7. Linux 删除用户时报错:userdel: user zhoulijiang is currently used by process 1

    一.发现问题: 有技术人员离职,需要删除系统帐号,但是进行删除操作的时候报:" userdel: user zhoulijiang is currently used by process ...

  8. 安装“Microsoft SQL Server 2014 Management Objects”时报错"Error Writing to file: Microsoft.SqlServer.XEvent.Linq.dll."

    问题: 当安装的软件依赖Microsoft SQL Server 2014 Management Objects时,会把这个组件打进安装包里,但是在服务器上安装时却报如下错误: “Error Writ ...

  9. 在ERP中定义用户时报错:SqlDateTime 溢出。必须介于 1/1/1753 12:00:00 AM 和 12/31/9999 11:59:59 PM 之间

    在ERP中定义用户时.   报错: SqlDateTime 溢出.必须介于 1/1/1753 12:00:00 AM 和 12/31/9999 11:59:59 PM 之间. 原因分析: ①没有正确初 ...

随机推荐

  1. AWT初步— 事件处理模型

    之前学习的内容只能形成一个用户界面,而用户不能对其有实际的操作,也就是说用户界面没有任何功能.要能够让图形界面接收用户的操作,就必须给各个组件加上事件处理机制.在事件处理的过程中,主要涉及三类对象: ...

  2. Salesforce小知识:在简档中设置Visualforce页面的权限

    简档(Profile)中的 Visualforce 页面访问权限 在Salesforce中,对于自定义的简档,可以设置"Visualforce 页面访问"的权限. Visualfo ...

  3. loadrunner 脚本优化-关联设置

    脚本优化-关联设置 by:授客 QQ:1033553122 关联的原理 关联也属于一钟特殊的参数化.一般参数化的参数来源于一个文件.一个定义的table.通过sql写的一个结果集等,但关联所获得的参数 ...

  4. 我的简历 PHP Java C# 技术总监

          石先生 ID:303321266 目前正在找工作 13611326258 hr_msn@163.com 男|32 岁 (1985/08/06)|现居住北京-海淀区|12年工作经验     ...

  5. C++ 获取当前正在执行的函数的相关信息

    (我的运行环境:win10x64+vs2015通过, 有的环境KUbuntu 8.04.1 x64 g++ 4.2.3也通过了)主要通过宏来实现:(注意,开头和结尾都是两个下划线) 1. __PRET ...

  6. [20180730]exadata与行链接.txt

    [20180730]exadata与行链接.txt --//最近一段时间在看<expert oracle exadata>,智能扫描的三大优化方法是:字段投影,谓词过滤,存储索引.大多数智 ...

  7. [20180408]那些函数索引适合字段的查询.txt

    [20180408]那些函数索引适合字段的查询.txt --//一般不主张建立函数索引,往往是开发的无知,使用trunc等函数,实际上一些函数也可以用于字段的查询.--//以前零碎的写过一些,放假看了 ...

  8. lua保留n位小数方法

    time:2015/04/21 1. string.format() function GetPreciseDecimal(nNum, n) if type(nNum) ~= "number ...

  9. 上下文管理器——with语句的实现

    前言 with语句的使用给我们带来了很多的便利,最常用的可能就是关闭一个文件,释放一把锁. 既然with语句这么好用,那我也想让我自己写的代码也能够使用with语句,该怎么实现? 下面具体介绍怎样实现 ...

  10. jumpserver堡垒机web终端支持复制粘贴功能

    公司最近内部搭建了一个jumpserver堡垒机,但是web终端连接Windows时候没法复制粘贴文字文本 然后找了一下jumpserver官方说明没找到相应的说明,但是知道是guacamole这个组 ...