join the MSSQLTips community

MSSQLTips.com - your daily source for SQL Server tips

Google
 
Web mssqltips.com

 
Grant Execute to all SQL Server Stored Procedures - MSSQLTips

MSSQLTips

MSSQLTips.com - your daily source for SQL Server tips
Welcome to MSSQLTips Sign in | Join | Help
in Search

Grant Execute to all SQL Server Stored Procedures

Last post 03-11-2009 8:57 AM by troytabor. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 03-20-2007 12:00 AM

    Grant Execute to all SQL Server Stored Procedures

    This post is related to this tip: Grant Execute to all SQL Server Stored Procedures

    http://www.mssqltips.com/tip.asp?tip=1203

  • 09-21-2008 4:40 PM In reply to

    • wtubin
    • Not Ranked
    • Joined on 09-21-2008
    • Posts 1

    Re: Grant Execute to all SQL Server Stored Procedures

    Good tips, but when you grant the permission to windows authentication users, need to add square branket for the user when pass the parameter. also the sp will need the following change:

    SELECT @CMD1 = 'GRANT EXEC ON ' + '[' + @OwnerName + ']' + '.' + '[' + @ObjectName + ']' + ' TO [' + @user +']'

  • 11-24-2008 6:19 PM In reply to

    Re: Grant Execute to all SQL Server Stored Procedures

     The stored procedure as written will only grant privileges to stored procedures and not stored functions.  To grant to both types change section 3's insert from:

    INSERT INTO #StoredProcedures (StoredProcOwner, StoredProcName)
        SELECT ROUTINE_SCHEMA, ROUTINE_NAME
          FROM INFORMATION_SCHEMA.ROUTINES
         WHERE ROUTINE_NAME NOT LIKE 'dt_%'
           AND ROUTINE_TYPE = 'PROCEDURE'
    

     to:

    INSERT INTO #StoredProcedures (StoredProcOwner, StoredProcName)
        SELECT ROUTINE_SCHEMA, ROUTINE_NAME
          FROM INFORMATION_SCHEMA.ROUTINES
         WHERE ROUTINE_NAME NOT LIKE 'dt_%'
           AND DATA_TYPE <> N'TABLE'
           AND (   ROUTINE_TYPE = N'PROCEDURE'
                OR ROUTINE_TYPE = N'FUNCTION')
    
  • 03-11-2009 8:57 AM In reply to

    Re: Grant Execute to all SQL Server Stored Procedures

    VERY easy for SQL Server 2005. 
    /* CREATE A NEW ROLE */
    CREATE ROLE db_executor
    
    /* GRANT EXECUTE TO THE ROLE */
    GRANT EXECUTE TO db_executor
    
    Troy
Page 1 of 1 (4 items)