How about to a particular Role? A user will not work for me in this instance...
Main Topics
Browse All TopicsHello,
I want to be able to update all stored procedures of a particular database with an execute permission (or deny)
I know that to do a certain procedure:
GRANT EXECUTE ON sp_someproc ON somerole
works.
Can I do
GRANT EXECUTE ON all procedures WHERE NOT EXECUTE or something?
Thanks.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
There are 2 possible approaches. The first simply involves granting the execute rights to each individual database user. The second creates a database role, assigns the role the appropriate rights and then assigns the new role to a set of users. As you can possible see the first solution is finel when all users have different rights (but ugly when it comes to the everything has got a role paradigm), the second one when a set of users share the same rights.
Ad solution1) /* not recommended since using roles is 'cleaner' */
The following script works for SQL2000 and higher:
declare @sql nvarchar(4000)
declare @db sysname ; set @db = DB_NAME()
declare @u sysname ; set @u = QUOTENAME('<insert_username
set @sql ='select ''grant exec on '' + QUOTENAME(ROUTINE_SCHEMA) + ''.'' +
QUOTENAME(ROUTINE_NAME) + '' TO ' + @u + ''' FROM INFORMATION_SCHEMA.ROUTINE
'WHERE OBJECTPROPERTY(OBJECT_ID(R
exec master.dbo.xp_execresultse
Ad solution 2)
CREATE ROLE somerole
GRANT EXECUTE TO somerole /* grants execute to all stored procedures/functions - even to ones that will be created at a later date */
/* or for each database object you can grant the execute explicitly */
grant execute on bartest to foobar
/* then assign the role to the user */
sp_addrolemember [ @rolename = ] 'role', [ @membername = ] 'security_account'
Business Accounts
Answer for Membership
by: DanielWilsonPosted on 2009-10-30 at 04:49:53ID: 25701958
No.
You can write a script that uses dynamic SQL and a cursor to grant execute on all procedures to a particular user.
Want code fro that?