We could easily grant execute permission to a user on all stored procedures on a database as below.
USE <database name>
GRANT EXECUTE TO <user>
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.
1234567USE <database name>GOSELECT 'EXEC(''GRANT EXECUTE ON'+OBJECT_SCHEMA_NAME(object_id)+'.' + name + 'TO [<domain\user>]'')'from sys.procedures ORDER BY nameGO
- 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.