February 22, 2011 at 9:16 am
Hi,
I have to drop and re-create a DB nightly.
When I do that my user loses it's mapping (read_only) to that DB.
Is there a way to create a script (that I can schedule as a job) that will recreate the read only mapping to that Db?
February 22, 2011 at 10:01 am
got it myself thanks anyway...
CREATE LOGIN [UserA] WITH PASSWORD=N'UserA',
DEFAULT_DATABASE=[OrphanedUsers],
CHECK_EXPIRATION=OFF,
CHECK_POLICY=OFF
GO
February 22, 2011 at 10:09 am
oh wait that's not gonna work that user already exists....
February 22, 2011 at 10:51 am
I assume you're adding the user back manually every day ? Take that script and put it into a new job, then schedule to run at the appropriate time after the database is created.
SQL ServerAgent -> Jobs -> <right click> NewJob
February 22, 2011 at 11:53 am
I'm creating only the DB mapping, the user is still there.
the mapping to the dbis what goes away
February 22, 2011 at 11:58 am
if the user exists in the DB which you just restored,
you can schedule a job to run this after you restore DB
EXEC sp_change_users_login 'update_one', @username, @username
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply