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. 【代码笔记】Web-ionic单选框

    一,效果图. 二,代码. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> ...

  2. 【代码笔记】Web-ionic checkbox(复选框)

    一,效果图. 二,代码. <!DOCTYPE html> <html> <head> <meta charset="utf-8"> ...

  3. 从零开始学习html(六)开始学习CSS,为网页添加样式

    一.认识CSS样式 <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type&quo ...

  4. Force.com 多租户架构

    本文参考自官方文档. 多租户架构 作为云计算平台的先驱,Salesforce最大的特点是"软件即服务"(Software as a Service,Saas).实现这种技术的基础便 ...

  5. Android View 绘制流程

    Android 中 Activity 是作为应用程序的载体存在,代表着一个完整的用户界面,提供了一个窗口来绘制各种视图,当 Activity 启动时,我们会通过 setContentView 方法来设 ...

  6. JMeter 参数化之利用CSV Data Set Config从文件读取参数并关联变量

    参数化之利用CSV Data Set Config从文件读取参数并关联变量   by:授客 QQ:1033553122 1.   添加CSV Data Set Config 右键线程组->配置元 ...

  7. Android Java语法学习

    Activity中有一个名称叫onCreate的方法.该方法是在Activity创建时被系统调用,是一个Activity生命周期的开始. onCreate方法的参数savedInstanceState ...

  8. 安装mysql(macos系统)

    1.到官网下载,直接百度"mysql"即可找到 2.双击安装包,一路安装即可 3.然后进到系统设置 4.接下来 输入coho的用户密码 设置root用户的密码 切换root用户,v ...

  9. Django之验证

    1. 滑动验证码补充说一下 极验科技:https://docs.geetest.com/install/deploy/server/python#下载SDK按照人家的实例操作即可 1.pip inst ...

  10. LeetCode题解之Second Minimum Node In a Binary Tree

    1.题目描述 2.问题分析 使用set. 3.代码 set<int> s; int findSecondMinimumValue(TreeNode* root) { dfs(root); ...