SQL Server Central is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
Search:  
 
 

Granting Execute Access to All Stored Procedures to a Given User

By Tim Mitchell, 2005/12/13

Total article views: 8423 | Views in the last 30 days: 53

Recently, I encountered a situation where I needed to give Execute permission for a particular user to all of the stored procedures I had created in my database.  Since there were a few hundred stored procedures, I had not intention of doing so manually for each procedure, and like any good geek, I wanted to find a way to reuse my solution in the future. 

So, to that end, I created a quick and dirty T-SQL script that will grant Execute permission on all stored procedures in the database.  You will need to enter your own values for the @login value, and of course you can limit the stored procedures being modified by restricting your results selected into the temp table.  If you find yourself needing this functionality frequently (I can't imagine why), you could always create a procedure from this code.

[Brief disclaimer: Please don't e-mail me and tell me that I should use a cursor for this.  Yes, I know this could also be done with a cursor.  However, for a variety of reasons too lengthy to list here, I prefer to use temp tables and/or loops instead of cursors whenever possible.]

Download the code

By Tim Mitchell, 2005/12/13

Total article views: 8423 | Views in the last 30 days: 53
Your response
 
 
Related tags

DTS    
SQL Server 7, 2000    
 
Related content

Locking Down DTS

By Brian Knight | Category: DTS
| 8,008 reads

DTS Basics

By Brian Knight | Category: DTS
| 10,171 reads
Already registered?  

Free registration required

To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.

Register

E-mail address:
Password:
Password (confirm):

  

Subscriptions

We ask you to register on the site and subscribe to our newsletters. Subscribing to our newsletters gets you:

  • ALL of our content (thousands of articles, scripts, and forum postings)
  • A daily newsletter (example)
  • A weekly news round up (example)
  • The opportunity to ask and answer questions in our forums
  • A daily Question of the Day to test and help you increase your knowledge of SQL Server.

We ask that you give the newsletter a try for a week. Over 200,000 SQL Server Professionals a day find it entertaining and useful. If not, you are welcome to unsubscribe at anytime.

Steve Jones
Editor, SQLServerCentral.com