Script to Grant differen Permission to SP, Scalar, Table-valued and inline functions.

  • Anyone have any script for the following:

    --GRANT EXEC permissions to all SPs and scalar functions to a DB role in a Database

    --GRANT SELECT permissions to table-valued and inline functions to a DB role in a Database

    Thanks,

    SueTons.

    Regards,
    SQLisAwe5oMe.

  • something like this?

    note you have to modify the role everytime a proc/function is dropped and created, or new ones added.

    CREATE ROLE MyExecProcRole;

    CREATE ROLE MyExecFuncRole;

    --GRANT EXEC permissions to all SPs and scalar functions to a DB role in a Database

    SELECT

    'GRANT EXEC ON '

    + schema_name(schema_id)

    + '.'

    + name

    + 'TO MyExecProcRole'

    FROM sys.objects

    where type_desc IN('SQL_STORED_PROCEDURE')

    --GRANT SELECT permissions to table-valued and inline functions to a DB role in a Database

    SELECT

    'GRANT SELECT ON '

    + schema_name(schema_id)

    + '.'

    + name

    + 'TO MyExecFuncRole'

    FROM sys.objects where type_desc IN('SQL_INLINE_TABLE_VALUED_FUNCTION',

    'SQL_SCALAR_FUNCTION',

    'SQL_TABLE_VALUED_FUNCTION')

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thanks Lowell, appreciate for your quick response.

    SueTons.

    Regards,
    SQLisAwe5oMe.

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

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