Grant Exec Rights on all Functions

  • Dear All,

    How to provide exec rights to a specific user on all User & System functions?

    Regards,
    Sarabpreet Singh 😎
    Sarabpreet.com
    SQLChamp.com
    Twitter: @Sarab_SQLGeek

  • You should always try to grant permissions to a role you've created and then put the appropriate users in that role. If you also want the role to have execute rights on all stored procedures as well, you can simply:

    GRANT EXECUTE ON SCHEMA::dbo

    Assuming all are in the dbo schema. If you only want functions, the best thing to do is use a query to build the permissions T-SQL for you:

    SELECT 'GRANT EXECUTE ON [' + SCHEMA_NAME(schema_id) + '].[' + [name] + '] TO MyRole;'

    FROM sys.objects

    WHERE type = 'FN';

    Then take the code you've generated and execute it.

    K. Brian Kelley
    @kbriankelley

  • K. Brian Kelley (10/3/2009)


    You should always try to grant permissions to a role you've created and then put the appropriate users in that role. If you also want the role to have execute rights on all stored procedures as well, you can simply:

    I know its a best practice, thanks. i'll do the same from now onwards.

    and thanks for the help Sir [:)]

    Regards,
    Sarabpreet Singh 😎
    Sarabpreet.com
    SQLChamp.com
    Twitter: @Sarab_SQLGeek

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

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