|
Is there an easy way to grant execute permissions for a user to all stored procedures at once rather than doing each one individually?
(comments are locked)
|
|
FYI
This will grant execute permission for all the objects to which this permission could be applied. Not just for the stored procedures but the scalar and aggregate functions, synonyms and CLR types too. This should be kept in mind.
(comments are locked)
|
|
To grant permissions for a user or role to execute any procedure in a database:
To grant permissions for a user or role to execute any procedure in any database: Excellent answer, but note that sp_msforeachdb is an undocumented procedure. I use it all the time, but people who use it should be aware of that. Using the sp_msforeachdb solution as written will grant execute on the master database, with all that implies.
Dec 08 '09 at 04:26 PM
TimothyAWiseman
Very good points. I agree with your concerns. I guess I should have noted that although sp_msforeachdb will work, it should be used with caution and only by someone who understands the full impact and risks.
Dec 08 '09 at 06:21 PM
Tom Staab
(comments are locked)
|
|
Depending on your schema structure, you could grant execute on a schema's procs i.e.
(comments are locked)
|
|
If there's no simplier way you can iterate through all the stored procedures in the db and grant the permissions on them. Here's an example:
This can be used inside a stored procedure whith a parameter for the username for flexibility.
(comments are locked)
|
|
If you are using SQL Server 2005 or 2008 and you want always grant You can easily modify the trigger to grant this permission to particular users or only grant permissions to stored proc in particular schema etc.
(comments are locked)
|

