This code uses the INFORMATION_SCHEMA.ROUTINES view, and has a check to exclude Microsoft objects.select [--Grant Permissions] = 'grant execute on ['+ ROUTINE_SCHEMA+'].['+ROUTINE_NAME+'] to MyRoleName'from INFORMATION_SCHEMA.ROUTINESwhere ROUTINE_TYPE = 'PROCEDURE' and -- Exclude Microsoft objects objectproperty(object_id('['+ROUTINE_SCHEMA+'].['+ROUTINE_NAME+']'),'IsMSShipped') <> 1order by ROUTINE_SCHEMA, ROUTINE_NAME
Results:--Grant Permissions----------------------------------------------------------------------grant execute on [dbo].[CustOrderHist] to MyRoleNamegrant execute on [dbo].[CustOrdersDetail] to MyRoleNamegrant execute on [dbo].[CustOrdersOrders] to MyRoleNamegrant execute on [dbo].[Employee Sales by Country] to MyRoleNamegrant execute on [dbo].[Sales by Year] to MyRoleNamegrant execute on [dbo].[SalesByCategory] to MyRoleNamegrant execute on [dbo].[Ten Most Expensive Products] to MyRoleName
CODO ERGO SUM