October 30, 2011 at 7:19 pm
I have a SS2008 database. I make changes to it in my local environment, save the bak file to the integration server and then restore the bak file to the SS instance on the integration server.
For some reason my login user mappings get messed up when I try to use this deployment approach.
* I have a MyLogin database user
* My MyLogin database user has db_datareader and db_datawriter permissions
* I have a MyLogin login in my server security
* My MyLogin login has a user mapping to MyLogin database user in my database
However, whenever I restore a new copy of my database into this configuration I can no longer login with my MyLogin user credentials.
I have to delete MyLogin database user and then create a new database user mapping from MyLogin in my database to a new MyLogin database user.
Can someone please explain if this is the expected behavior or if I'm doing something wrong here? It's kind of a hassle to have to go through this reconfiguration process everytime I deploy a new version of the database.....
October 31, 2011 at 2:09 am
Expected behaviour because when you created the login on the other server you used the same name but did not specify the SID. Hence the SID is different between the servers, hence the logins don't match.
Google - orphaned users.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
October 31, 2011 at 1:11 pm
You can associate (re-sync-if you will) database users with server logins on the destination server using the sp_change_users_login procedure. For example:
exec sp_change_users_login 'UPDATE_ONE', 'dbUserName', 'loginName'
See: http://msdn.microsoft.com/en-us/library/ms174378(v=SQL.100).aspx
October 31, 2011 at 7:24 pm
Actually, sp_change_users_login is deprecated in 2008. It has been replaced by the ALTER USER statement.
ALTER USER [username] WITH LOGIN = [login name]
November 3, 2011 at 3:08 pm
I tried:
alter user [MyUser] with login [MyLogin]
However, SS returns the following error: "Incorrect syntax near 'MyLogin'."
I tried executing this query in the main app database as well as master and got the same error when executing in the context of either database....
November 3, 2011 at 3:23 pm
You left out the =
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
November 3, 2011 at 10:35 pm
GilaMonster (11/3/2011)
You left out the =
Thanks Gail - that was the problem.....
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply