Error: "User, group,
or role 'someuser' already exists in the current database. (Microsoft SQL
Server, Error: 15023)".
The above error arises once I restore
the database and try to log in on it. Sadly, it does not seem to be up to the
task of fixing this issue using SQL Management Studio alone.
To fix this issue, you have to open a
query window in SQL Server Management Studio and execute the following SQL
query steps.
1- Get User Information
If you have the information about the
users, then you can skip this step. If not then use the following query.
USE DatabaseName
GO
EXEC sp_change_users_login 'Report'
GO
|
This query will return the result set
of users.
2- Fix the issue one by one for the users
The following query will responsible
for fixing the issue.
USE Database
GO
EXEC sp_change_users_login 'Auto_Fix', 'user'
GO
|
Result:
The row for user '****' will be fixed
by updating its login link to a login already in existence.
The number of orphaned users fixed by
updating users was 1.
The number of orphaned users fixed by
adding new logins and then updating users was 0.**
|
If you want to create a new user password
then also you can use the above query as below.
USE Database
GO
EXEC sp_change_users_login 'Auto_Fix', 'user', NULL, 'password'
GO
|
No comments:
Post a Comment
Please do not enter any spam link in the comment box.