You may run into the 15023 error if you restore a MS SQL database from backup. You expect a restored database to be in exactly the same state as the backup, but the login fails for a user that had permissions in the backed up database. When you use the "User Mapping" SQL Management Studio functionality to allow the user permissions to the new database, you receive the 15023 error. This is caused by Security identification numbers (SID) that are mismatched or 'orphaned' in the sysusers table.
The SQL Server stored proc sp_change_users_login locates and fixes these records. Run it with a single parameter 'Report' to get a listing of abandoned user names and corresponding SIDs:
exec sp_change_users_login Report
The 'Update_One' parameter will reconnect a single login:
exec sp_change_users_login Update_One, 'MyLogin', 'MyLogin'
You can find more info about this issue at:
http://support.microsoft.com/kb/246133
http://support.microsoft.com/kb/240872
This next blog expands on the available parameters for sp_change_users_login:
http://blog.sqlauthority.com/2007/02/15/sql-server-fix-error-15023-user-already-exists-in-current-database/
Also, try checking out the source for sp_change_users_login found in the Sql Server Management Studio under Databases | System Databases | Master | Programmability | Stored Procedures | sp_change_users_login.
Remember Me
a@href@title, i, strike, u
Copyright © 2003-2008 Falafel Software Inc.
Subscribe to Falafel Blogs
The opinions expressed herein are Falafel's employees own personal opinions and do not represent Falafel Software's view in any way in case they go bananas!