15138: The database principal owns a schema in the database, and cannot be dropped(数据库主体在数据库中拥有架构,无法删除)
SQL Server含义
尝试删除数据库用户/角色(数据库主体),但由于该主体拥有数据库中的一个或多个架构而无法删除。在将其拥有的架构转移给其他主体之前无法删除。
原因
要删除的用户是至少一个架构的 OWNER(例如默认以其名称创建的架构,或通过 AUTHORIZATION 指定的架构)。为避免留下孤立架构,SQL Server 阻止删除。
解决方法
找出该用户拥有的架构:SELECT name FROM sys.schemas WHERE principal_id = USER_ID('app_user'); 将这些架构的所有权转移给其他主体(例如 dbo):ALTER AUTHORIZATION ON SCHEMA::[app_schema] TO dbo; 如果该架构不再需要(且为空),执行 DROP SCHEMA。所有权转移后,再次运行 DROP USER。
同一数据库的其他条目
- 8651Could not perform the operation because the requested memory grant was not available(无法执行操作,因为请求的内存授予不可用)
- 5061ALTER DATABASE failed because a lock could not be placed on database(ALTER DATABASE 失败,因为无法在数据库上加锁)
- 3702Cannot drop database because it is currently in use(无法删除数据库,因为它当前正在使用)
- 1934INSERT/UPDATE failed because the following SET options have incorrect settings(INSERT/UPDATE 失败,因为以下 SET 选项的设置不正确)
- 468Cannot resolve the collation conflict(无法解决排序规则冲突)
- 4864Bulk load data conversion error (type mismatch or invalid character)(大容量加载数据转换错误(类型不匹配或无效字符))
- 916The server principal is not able to access the database under the current security context(服务器主体无法在当前安全上下文中访问数据库)