We could easily grant execute permission to a user on all stored procedures on a database as below.
GO GRANT EXECUTE TO GO
But unfortunately, our database will be at risk since the user would have got access to almost all stored procedures including the system stored procedures in that database. Hence use below steps to grant access to non-system stored procedures securely.
- Run below script on the database and copy the output.
GO SELECT 'EXEC(''GRANT EXECUTE ON '+OBJECT_SCHEMA_NAME(object_id)+'.' + name + ' TO [ ]'')' from sys.procedures ORDER BY name GO
- Paste the output to a new query window.
- Add “USE <database name>” at the beginning of the pasted output code and execute.
Note: Values inside ‘<‘ and ‘>’ has to be replaced with your actual database name and user information where ever required.