Results 1 to 9 of 9

Thread: SQL 2005 - user rights

  1. #1
    Join Date
    May 2005
    Posts
    111

    SQL 2005 - user rights

    I need to grant a user to view all stored procedures in a database. Is there a server role other than sysadmin that grants said permissions? If not, does anyone have a script that will give a resultset of all SP's in a database so i can alter the scripts output to grant view to a specific user?

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    What do you mean view? User can list sp names? Can execute them or just look at code?

  3. #3
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    You can grant EXECUTE permission on the schema that owns stored procedure to the user.

  4. #4
    Join Date
    May 2005
    Posts
    111

    answer: view code

    view the code.

  5. #5
    Join Date
    Sep 2002
    Posts
    5,938
    Need view definition permission on sps.

  6. #6
    Join Date
    May 2005
    Posts
    111
    i know i can grant said permissions on individual sps however, i want to grant a user view permissions for all sps and there are a lot of them. is there a script to grab all sps' in a database so i can script something out and give a user view to all sps?

  7. #7
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    select name from sys.procedures

  8. #8
    Join Date
    Sep 2002
    Posts
    5,938
    Try following, it'll generate grant statements you need. Replace user with user name or db role:

    SELECT 'grant view definition on ' + name + ' to user' FROM sys.procedures

  9. #9
    Join Date
    May 2005
    Posts
    111
    that's exactly what i was looking for. as always---thanks for the help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •