I have to restore our production database to a test instance on a daily bases. This test instance gives people access to the data that we do not want changing production data. When I restore the database there are logins in the test instance with access to the database that do not have a login or user account in production instance. So I have a script that goes and adds each user to the users list in the restored database on the test instance. This list of users changes more than I would like. So I am always making changes to the script.
Does any one know a way to pull a list of instance logins with access to the restored database and add them to the user list of the restored database. I have to add them with read, write and execute permissions
Thanks
Best Answer
If I follow what you're saying correctly. You have db users in test, which are not in prod. When you restore from prod, all these users lose access. At the moment you have a static script which puts all the access back after the restore. You need to do this more dynamically. What I would do is:
Try to structure user access around roles if you haven't done so already. This will simply the process.
Here's a script I use: