Bobcares

How to fix SQL Server Error 15023

by | Jul 18, 2020

The SQL Server Error 15023 arises during user mapping when you restore a database to a different server.

Here at Bobcares, we have seen several causes for this error while troubleshooting SQL issues as part of our Server Management Services for web hosts and online service providers.

Today we’ll take a look at the cause for this error and how to fix it.

 

More about SQL Server Error 15023

In SQL Server, backup and restore are simple tasks. The only problem that arises here is the user mapping don’t work when you restore the database to a different server. If you try to map database to a user by going to

Security >> Logins >> right click some user >> Properties >> User Mapping >> Select DB >> set as db_owner and then ok, the following error is received as shown in image:

SQL Server Error 15023

 

What causes SQL Server Error 15023 to occur

Normally, when we backup and restore databases across the SQL servers, we are only restoring a user database and not the master database where logins are kept.

After restoring we expect the restored database to work in the same way as the backup. But the login fails for a user that had permissions in the backed up database. This issue caused due to Security identification numbers (SID) that are mismatched or ‘orphaned’ in the sysusers table.

 

How we fix SQL Server Error 15023

Recently, one of our customers approached us with the same error message. Now, let’s see how our Support Engineers resolve this error.

1) Initially, we ran the following T-SQL Query in Query Analyzer. This will return all the existing users in database in result pan.

USE YourDB
GO
EXEC sp_change_users_login ‘Report’
GO

To associate login with the username, we ran the following T-SQL Query in Query Analyzer. Here, ‘Auto_Fix’ attribute will create the user in SQL Server instance if it does not exist.

Also, in the query we updated the ‘Username’ with actual customer username and ‘Password’ with actual Password. Auto-Fix links a user entry in the sysusers table in the current database to a login of the same name in sysxlogins.

USE YourDB
GO
EXEC sp_change_users_login ‘Auto_Fix’, ‘Username’, NULL, ‘Password’
GO

To associate login with the username, we ran the following T-SQL Query in Query Analyzer. Here, ‘Update_One’ will link the specified user in the current database to login. Here, login must already exist, user and login must be specified and password must be NULL or not specified.

USE YourDB
GO
EXEC sp_change_users_login ‘update_one’, ‘ColdFusion’, ‘ColdFusion’
GO

2) We ran the following T-SQL in Query Analyzer since the login account had permission to drop other users. This query will drop the user.

USE YourDB
GO
EXEC sp_dropuser ‘ColdFusion’
GO

Then we created the same user again in the database without any error.

[Need any further assistance in fixing SQL errors? – We’re available 24*7]

 

Conclusion

In short, This SQL error can arise during user mapping when you restore a database to a different server. Today, we saw the resolution to this SQL error.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

3 Comments

  1. Nicky B. Lusdoc

    thanks bobcares. I am so thankful for your support…

    Reply
    • Hiba Razak

      Hi Nicky,
      Thanks for the feedback.

      Reply
  2. Hakan

    Thanks super

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.