SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Permissions issue upon a restore


Permissions issue upon a restore

Author
Message
sqlstar2011
sqlstar2011
Mr or Mrs. 500
Mr or Mrs. 500 (559 reputation)Mr or Mrs. 500 (559 reputation)Mr or Mrs. 500 (559 reputation)Mr or Mrs. 500 (559 reputation)Mr or Mrs. 500 (559 reputation)Mr or Mrs. 500 (559 reputation)Mr or Mrs. 500 (559 reputation)Mr or Mrs. 500 (559 reputation)

Group: General Forum Members
Points: 559 Visits: 592
Every now and then when we restore production databases in development environment we get a few emails from developers complaining about that they are unable to do something or just cant log in to the database. Those that we remember to give permissions to are happier but those we forget or just are left out just aren't happy. I don't blame them because there is a hole in our process.

I was wondering if there is a script that can help me extract all the permissions from an existing database in development environment, whether the permissions are at the object level (table, view) or whether at the role level (dbo, db_reader etc.) so every time after the restore from Prod I can just run this script of permissions and keep everyone happy.

Thoughts?

Thanks
sturner
sturner
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2262 Visits: 3259
I have proc that will script out all the users, roles and their permissions if you want it.

But I would make two other suggestion which would be simpler:

1) import the logins from the production server to the development server then you won;t have to worry about it anymore.

2) if you can't do that, always remeber to run sp_change_users_login for the SQL serve logins after you restore your production database.

The probability of survival is inversely proportional to the angle of arrival.
sqlstar2011
sqlstar2011
Mr or Mrs. 500
Mr or Mrs. 500 (559 reputation)Mr or Mrs. 500 (559 reputation)Mr or Mrs. 500 (559 reputation)Mr or Mrs. 500 (559 reputation)Mr or Mrs. 500 (559 reputation)Mr or Mrs. 500 (559 reputation)Mr or Mrs. 500 (559 reputation)Mr or Mrs. 500 (559 reputation)

Group: General Forum Members
Points: 559 Visits: 592
Infact the issue that we run into most often is that some of these folks in prod have db_reader access whereas in dev they want full control as dbo so they can do whatever it is that would like. So my goal is to extract permissions from dev environments and just re-apply them after the restore.

Would you be kind enough to share your script.

Thanks
sturner
sturner
SSCrazy
SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)SSCrazy (2.3K reputation)

Group: General Forum Members
Points: 2262 Visits: 3259
yes I can, but from what you are describing, scripting out the roles and permissions from production and executing it on the dev server will not give you what you want (users having more permissions on dev)

Would it not be easier to simply run a pre-built script that has your necessary grant statements and/or sp_addrolemember SP calls?

The probability of survival is inversely proportional to the angle of arrival.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search