Scripting Database roles

  • Hi,

    I searched this site and found plenty of good scripts and Stored Procedures for displaying the permissions for a User defined Database Role.

    How would I go about Scripting out the Database Role so that it will generate the Grant statements needed to recreate the Database Role?

  • Have you seen this one? http://www.sqlservercentral.com/scripts/SQL+Server+7%2c+2000/61878/. I've used it to document some of my instances.

    Greg

  • Greg Charles (3/2/2010)


    Have you seen this one? http://www.sqlservercentral.com/scripts/SQL+Server+7%2c+2000/61878/. I've used it to document some of my instances.

    That's a good script.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • I did see that one.. it errors out on me..

    Msg 102, Level 15, State 1, Procedure sp_ScriptRoles, Line 4

    Incorrect syntax near '?'.

    Msg 137, Level 15, State 2, Procedure sp_ScriptRoles, Line 74

    Must declare the scalar variable "@Role".

    Msg 102, Level 15, State 1, Procedure sp_ScriptRoles, Line 112

    Incorrect syntax near '?'.

    Msg 102, Level 15, State 1, Procedure sp_ScriptRoles, Line 340

    Incorrect syntax near 'END'

  • Jpotucek (3/2/2010)


    I did see that one.. it errors out on me..

    Msg 102, Level 15, State 1, Procedure sp_ScriptRoles, Line 4

    Incorrect syntax near '?'.

    Msg 137, Level 15, State 2, Procedure sp_ScriptRoles, Line 74

    Must declare the scalar variable "@Role".

    Msg 102, Level 15, State 1, Procedure sp_ScriptRoles, Line 112

    Incorrect syntax near '?'.

    Msg 102, Level 15, State 1, Procedure sp_ScriptRoles, Line 340

    Incorrect syntax near 'END'

    It looks like it may have copied some non-printing characters. Check script in something like notepad++.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • try this one

    change the extension from .txt to.sql

    Sanket Ahir
    Don't run behind the success, Try to be eligible & success will run behind u......

  • Thank you .. that worked.

    I created the SP in my master DB and then executed it like this:

    Exec changemanagement_Training..sp_ScriptRoles

    and I got this?

    Msg 451, Level 16, State 1, Procedure Sp_scriptroles, Line 45

    Cannot resolve collation conflict for column 1 in SELECT statement.

Viewing 7 posts - 1 through 6 (of 6 total)

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