How to script GRANT perms to ALL OBJECTS

  • What is a quick way to grant ALL DATABASE objects (SELECT, etc) to a user or role via a script or utility? As I develop databases and/or make backups, I need to easily and quickly script fast permissions. I used to see a utility called Sqlgrant.exe on SWNYK but cannot find it. Surely, there's a script to enumerate all objects and assign perms....

    Grant SELECT on ???? to ROLE_Test

    Help would be appreciated!

  • A blanket approach, just change the type to reflect the object(s) you want to grant:

    SELECT "GRANT SELECT ON "+name+" TO <role/user>"

    FROM sysobjects

    WHERE type IN ("U","V")

    ORDER BY NAME

    SELECT "GRANT EXEC ON "+name+" TO <role/user>"

    FROM sysobjects

    WHERE type = "P"

    ORDER BY NAME

    Be great!

    Michael


    Be great!
    Michael

  • A MILLION thanks! You just saved tons of time! XOXOXOX!

Viewing 3 posts - 1 through 2 (of 2 total)

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