Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Granting Execute Access to All Stored Procedures to a Given User

By Tim Mitchell,

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

Total article views: 9484 | Views in the last 30 days: 5
 
Related Articles
FORUM

Using Cursors Inside Stored procedure problem

creating cursor inside stored procedure gives error

FORUM

Inserting rows Using Cursors in Stored Procedure

Inserting rows Using Cursors in Stored Procedure

FORUM

Running Oracle stored procedures from SQL server 2005

Running Oracle stored procedures with REF CURSOR

FORUM

stored procedure

stored procedure

FORUM

Creating view from stored procedure results

Creating view from stored procedure results

Tags
dts    
sql server 7    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones