Geeks With Blogs
Mayank Sharma

I was moving a lot of databases from one SQL Server to another, and my applications were giving me errors saying "Login failed for <user>". The user was already in the database with appropriate rights to allowed objects in the database. I tried mapping the user to the database and that's when I got this message:

"User Already Exists in the Current Database"...

I googled and found this very useful post about orphaned users when moving databases.

These are the steps you should take to fix this issue:

First, make sure that this is the problem. This will lists the orphaned users:
EXEC sp_change_users_login 'Report'

If you already have a login id and password for this user, fix it by doing:
EXEC sp_change_users_login 'Auto_Fix', 'user'

If you want to create a new login id and password for this user, fix it by doing:
EXEC sp_change_users_login 'Auto_Fix', 'user', 'login', 'password'

Posted on Wednesday, April 21, 2010 7:59 AM SQL Server | Back to top


Comments on this post: User Already Exists in the Current Database - SQL Server

# re: User Already Exists in the Current Database - SQL Server
Requesting Gravatar...
Thanks for this.
Left by Paul on Mar 18, 2013 8:29 PM

# re: User Already Exists in the Current Database - SQL Server
Requesting Gravatar...
Im getting this message. I cant figure this out for the life of me. It wont let me delete the user since it owns a full text catalog in the database and I cant create user mappings since it already shows the user in the database. Please help its urgent. Thank you.

Msg 15600, Level 15, State 1, Procedure sp_change_users_login, Line 214
An invalid parameter or option was specified for procedure 'sys.sp_change_users_login'.
Left by Grippy on Apr 10, 2013 1:33 AM

# re: User Already Exists in the Current Database - SQL Server
Requesting Gravatar...
Did you try the suggestions in the post?
Left by max on Apr 10, 2013 11:01 AM

# re: User Already Exists in the Current Database - SQL Server
Requesting Gravatar...
Thank you for this. This is exactly what I needed.
Left by David on Apr 26, 2013 2:10 PM

Your comment:
 (will show your gravatar)


Copyright © bullpit | Powered by: GeeksWithBlogs.net