Scripting out permission for database?

  • Hi All,

    moving databases from Prod to new server. And also want to carry forward permissions.

    Need help on moving permissions.

    thanks in advance.

  • you'll need to get a copy of sp_help_revlogin from microsoft; there are different versions, depending on 2000/2005, maybe even for 2008 and above, i don't quite remember.

    assuming you are going to do a backup from Prod and Restore on the new server, you should be good with that...object permissions are stored int eh databases themselves, and the procedure above will carry the correct sids along with it, so that makes it fairly seamless.

    don't forget all the other things on production, like certificates, linked servers,

    and more; theres a current thread on side by side server migration you might want to peek at:

    http://www.sqlservercentral.com/Forums/Topic1384265-391-1.aspx

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thanks for your replay,

    If I am doing refresh from PROD to DEV.

    I need take a backup script out permissions for a database before restoring in DEV.

    and restore the permissions back in DEV, when the refresh is done.

    So, I need help in scripting out permissions for a database..

  • try this[/url], exactly what you want.

    read the discussion afterwards as well

    ---------------------------------------------------------------------

  • It did'nt help....

    I need help in scripting out permissions for a database.

    Please don't say sp_help_revlogin: It gives list out all the logins on a server.

  • User permissions are stored in the database. If i take a backup of MyDatabase and restore it onto a different server all the permissions are going to be the same. the problem comes in when you create users on the new database machine, you will end up with "Orphaned" users in the database. You have two options you can use sp_help_revlogin or you can use ALTER USER http://msdn.microsoft.com/en-us/library/ms189828.aspx to map the orphaned users to a SQL Server login. Once you have mapped the Logins to Database users (or using sp_help_revlogin you do not have to go through this step as the SID's of the users will remain the same) all the permissions will be there.


    For faster help in answering any problems Please read How to post data/code on a forum to get the best help - Jeff Moden[/url] for the best way to ask your question.

    For performance Issues see how we like them posted here: How to Post Performance Problems - Gail Shaw[/url]

    Need to Split some strings? Jeff Moden's DelimitedSplit8K[/url]
    Jeff Moden's Cross tab and Pivots Part 1[/url]
    Jeff Moden's Cross tab and Pivots Part 2[/url]

  • Danzz (11/14/2012)


    It did'nt help....

    I need help in scripting out permissions for a database.

    Please don't say sp_help_revlogin: It gives list out all the logins on a server.

    You asked for a script to list database permissions and that is exactly what it does, how did it not help?

    ---------------------------------------------------------------------

  • sp_help_revlogin : List outs all the logins from the server,

    I dont want all the logins.

    I just need for a list all the logins in a database:

    which include login, roles, grant permissions.

    Any help is greatly appreciated..Thanks in advance.

  • have you looked at the link i posted?

    ---------------------------------------------------------------------

  • Georges link again for clarity:

    http://www.sqlservercentral.com/scripts/Permissions/76450/

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • See the following url for an Instance Security Audit script I wrote. It prints in columnar format, and you can change one variable to make it print the actual assignment statements for the permissions. The posting explains a little more.

    Hope it helps.

    http://www.sqlservercentral.com/Forums/Topic1251262-146-1.aspx?Update=1

  • vikingDBA (11/16/2012)


    See the following url for an Instance Security Audit script I wrote. It prints in columnar format, and you can change one variable to make it print the actual assignment statements for the permissions. The posting explains a little more.

    Hope it helps.

    http://www.sqlservercentral.com/Forums/Topic1251262-146-1.aspx?Update=1

    If you want to share this you would be better posting it in the scripts section

    ---------------------------------------------------------------------

  • You could try:

    Right-click on db name, select Tasks -> Generate Scripts

    There you have a number of scripting options including scripting out Users, Roles, and Schemas. There is an advanced options tab that will give you even more choices of what to put in the script output.

     

  • hey I try to execute (Reverse-Engineer Database Permissions (2005 up)) http://www.sqlservercentral.com/scripts/Permissions/76450/

    I am getting error.

    Msg 102, Level 15, State 1, Procedure usp_get_object_permissions, Line 44

    Incorrect syntax near '?'.

    Msg 102, Level 15, State 1, Procedure usp_get_object_permissions, Line 50

    Incorrect syntax near '?'.

  • looks like some sort of problem with the copy\paste from the site.

    click on the error message in the results pane and it will take you to the actual error in the code. Its purely syntax so some character has been misinterpreted.

    Remember to go through the discussion on the script to get an improvement to part of it.

    ---------------------------------------------------------------------

Viewing 15 posts - 1 through 14 (of 14 total)

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