Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

GRANT on all SP's?

Status
Not open for further replies.

Hansje

Programmer
Dec 3, 2003
16
NL
So how can I GRANT EXECUTE on all stored procedures in a database, without using a cursor? Is this possible? Sofar I have not been able to get this done.
A step further: is it possible to GRANT EXECUTE on every stored procedure in every userdb, again without using a cursor?
 
select 'grant exec on ' + name + ' to joeblow
GO'
from sysobjects
where type = 'p'

Take the results, paste them in a new query window and run.

This will work for all the SP's in a specific DB, if you want to do all DB's, you'll need to get creative using the sysdatabases table in the Master DB and then running the above query for each DB.
 
Also check out FAQ1834107 (and the web) for sp_MSforeachdb.
This system stored proc will execute your statement against every single db, so you would have to include an if statement to make sure the particular db is a user one
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top