mssql数据库 用户、组或角色’XXX’在当前数据库中已存在 错误:15023

迅恒数据中心

环境:

从mssql 2000迁移到MSSQL 2008或2005,采用分离与附加数据库的方法。数据库正常加载,在添加数据库访问帐号时报如下错误:

用户、组或角色’XXX’在当前数据库中已存在 错误:15023

mssql用户存在


根据MSDN的一篇帖子得出解决办法:

1、查询数据库中存在的登陆用户

Use [YourDatabase]
Go

this will report all the orphaned login
EXEC sp_change_users_login @action='Report';

this should fix a orphaned user
Exec sp_change_users_login @action='Update_One', @UserNamePattern= [orphaneduserDBUserName] , @LoginName=[orphaneduserloginname]

就是最后这一句Update_One 将数据库中已经存在的帐号名更新为新创建的数据库帐号,以使新帐号生效。

 

分类:建站知识 百度收录 必应收录