When you do a database restore from a backup that was taken from a different machine, you also get all the users from that environment (and their SQL Ids).
So, the scenario is... I backup my production database, and then I restore that production database locally. The user that resides in my web.config file is correct (correct username and password). However, the actual user that is in my local database is the production user (meaning it holds the production user's SQL Id). I have the very same user, with the very same password... but this is not the same user.
Ok, now, how to fix this... Very easy trick a co-worker had in his bag of tricks:
sp_change_users_login 'auto_fix', '{userid}'
* where {userid} is the user id that you have locally, as well as restored from the production restore.
So, in my case, it would be something like:
sp_change_users_login 'auto_fix', 'DMSPFR'
This will fix my local database to reference my local DMSPFR user; not the production DMSPFR user.
No more then a few paragraphs of things I want to archive (instead of try to remember)
Tuesday, August 12, 2008
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment