Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 mapping login to db error

Author  Topic 

Hommer
Aged Yak Warrior

808 Posts

Posted - 2013-01-30 : 11:14:15
Hi,


We have a login on the dev server which mirrors the login on the production server, but I can't get it to mapped to another db in the same server group on the dev. When I edit the properties of the login in 'User Mapping", I check the map to 2nd db, and I get the following error:


Create failed for User 'myLogin_name'. (Microsoft.SqlServer.Smo)

User, group, or role 'mylogin_name' already exists in the current database. (Microsoft SQL Server, Error: 15023)

I know that user exists as it was listed under that db's security, users.

Thanks!

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2013-01-30 : 11:32:56
sounds like that user exists in the database but is not sync'd to the login (sids don't match). That can happen when the database is restored from a different server.

see if the user exist by:
use <database>
select * from sysusers where name = 'mylogin_name'

if its there then sync the user to the login with:
alter user [myLogin_name] with login = [myLogin_name]


Be One with the Optimizer
TG
Go to Top of Page

Hommer
Aged Yak Warrior

808 Posts

Posted - 2013-01-30 : 12:02:07
That worked!

Thanks, TG!
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2013-01-30 : 13:25:52
Cool - You're welcome.

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -