Grant execute permission on all user defined stored procedures having a database

  • Hi;

    I want to grant execute permission on all user defined stored procedures of database.not on system store procedures of database.

    when we create/restore a database, it create store procesdure in 2 category

    1 - system store procedures

    2 - store procedures other than system SP. (created by developer or programer)

    I have an DB ID and want to grant execute permission on only 2 type of store procedures by using SQL query.

    do we have any query to grant execute permission on all user define sp (other than system sp) on a particular database.

  • If you want to cover them all and you have SQL Server 2005 and higher as your SQL Server version, then GRANT EXECUTE against the appropriate schema (usually dbo). For instance:

    GRANT EXECUTE ON SCHEMA::dbo TO SomeDBRole;

    K. Brian Kelley
    @kbriankelley

  • Hi;

    Thanks for the reply, but let me further define my target.

    I have attached a snap shot of my database (please review)

    in this picture I have a folder "system stored procedures" having many default system store procedures, I dont want to give permission to DB ID for any system store procedures

    in picture we also have some store procedures (out side the folder of system store procedures) I want to give execute permission to DB ID only for these store procedures.

    I hope it will clarify my objective, Thanks

  • in addition to abbove, DB ID having only read & write permission to database. can not grant dbo access.

  • I think you have three options, then:

    (1) Do as Brian suggested, but then explicitly deny EXECUTE on all system stored procedures.

    (2) Move your user-defined stored procedures to a different schema and grant EXECUTE on that

    (3) Grant EXECUTE individually on user stored procedures. This has the disadvantage that you have to remember to do this on every new proc that you create after that. You can generate your own script to do this:

    SELECT 'GRANT EXECUTE ON ' + ROUTINE_NAME + ' TO <UserOrRole>'

    FROM INFORMATION_SCHEMA.ROUTINES

    WHERE ROUTINE_TYPE = 'PROCEDURE'

    John

  • Thanks you so much, I am abe to acheive my target by the help of your query.

    Thanks Take Care

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

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