Sunday 31 March 2013

Error 15023: User already exists in current database.

An annoying thing that can happen with MSSQL Server, when you move a database to a new server by backing it up on one and then restoring it on the other, is that the server can tell you the username already exists, when you attempt to create it.


The specific error is:

    Error 15023: User already exists in current database.


 RESOLUTION:

    1. Open a new query.
    2. Run the query: USE databasename
    3. Run the query (this will show the users for the DB): EXEC sp_change_users_login ‘Report’ 
    4. Run the query: EXEC sp_change_users_login ‘Auto_Fix’, ‘username‘, NULL, ‘password‘
        *Note: Replace 'username' with database user name  and 'password' with its respective password.

No comments:

Post a Comment