PROD to QA

  • I’ve moved a copy of prod db over to QA server, now I’m trying to fix logins (match sids.. etc) on QA server by running (sp_change_users_loign and it doesn’t work).  Other way I could do is by scripting users on source server and running it on target.  I’m trying to do a test where Prod1 SQL 2000 server fails and I’ve the backup in the tape drive.  I would restore on prod2 from the backup, how can I fix logins in this case? It’s sort of a DR question.  Can anybody help on this plz?  Thanks

     

  • anybody?

  • What goes wrong when you run sp_change_users_login? 

    Greg

    Greg

  • I get something like..

    Server: Msg 15290, Level 16, State 1, Procedure sp_change_users_login, Line 166

    Terminating this procedure. The Action 'AUTO_FIX' is incompatible with the other parameter values ('UserName', '(null)').

  • Hmm.  AUTO_FIX only works if the user name and login name are identical.  If they're not, you'll have to use the UPDATE_ONE argument and specify the user and login that you want link.  Is that the problem?

    Greg

    Greg

  • Login doesnt exist on the server but users are part of user db which are need to be fixed on QA server.  Update_one doesnt help either:

    sp_change_users_login 'update_one', TestUser, 'TestUser'

    Server: Msg 15291, Level 16, State 1, Procedure sp_change_users_login, Line 96

    Terminating this procedure. The Login name 'TestUser' is absent or invalid.

  • sp_change_users_login doesn't create logins; it maps existing users to existing logins.  If the login doesn't exist on the QA server, you'll need to create it then map the database user to it.

    Greg

    Greg

  • So users should be scripted on weekly basis in case of DR, databases/users/jobs can be move to other server if you are in standalone environment??

     

  • Users and logins are two different things.  Users are copied with the database when you restore or attach it to the QA server.  Logins must be copied over by scripting, by a DTS transfer logins task, or some other method.

    You want to make sure the logins are created with the same SID on the QA server that they had on the prod server, then you can avoid all the sp_change_users_login calls.

  • Yes, the sp_help_revlogin procedure in this article makes it easy to script logins: http://support.microsoft.com/kb/246133/en-us.  I've used it many times.  Logins only need to be transferred when a new one is added to the prod server.

    Greg

    Greg

  • In SQL 2005 and SQL 2000 SP3 and later, sp_change_users_login does create a login if it is missing, so there is no need to have to script all logins and create them first.

    This only works with the auto_fix action.

    Syntax

    sp_change_users_login [ @Action = ] 'action'

        [ , [ @UserNamePattern = ] 'user' ]

        [ , [ @LoginName = ] 'login' ]

        [ , [ @Password = ] 'password' ]

  • "sp_change_users_login does create a login if it is missing"

    But, again, only if the user and login have the same name.

    Greg

    Greg

Viewing 12 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic. Login to reply