sql server 删除用户时报错:(存在该用户的组织构架,无法删除)
解决方案:通过UI操作,在组织构架中把该用户的构架权限还给系统先,然后再通过UI直接将该用户删除即可。
use [your_db_name]
go
SELECT
N’ALTER AUTHORIZATION ON SCHEMA::’
+ QUOTENAME(SCH.name)
+ N’ TO [dbo];’,
*
FROM sys.schemas SCH WITH(NOLOCK)
INNER JOIN sys.database_principals DP WITH(NOLOCK)
ON DP.principal_id = SCH.principal_id
WHERE DP.type IN(‘S’, ‘G’, ‘U’)
AND DP.name = N’zhang.san’ – 要删除的用户
– run 一下生成的sql脚本 (必须)
—-ALTER AUTHORIZATION ON SCHEMA::[db_datareader] TO [dbo];
—-ALTER AUTHORIZATION ON SCHEMA::[db_datawriter] TO [dbo];
USE [your_db_name]
GO
DROP USER [zhang.san]
GO