Technical Article

Grant Execute Permissions to All Procedures

,

This procedures grants execute permissions to all the stored procedures in a database to the role/user supplied as the parameter. the default is Execute_StoredProcedure. Execute this procedure local to the database you need to grant permissions.

Use master
go
/*  
This procedure grants Execute permissions to all procedures on a database to the role desired.  
The default role is Execute_storedprocedure  
*/  
CREATE procedure sp_grant_permissions_proc @role varchar(100)='Execute_StoredProcedure' as  
declare curname cursor for select name,user_name(uid) from sysobjects where xtype = 'P'  
declare @procname varchar(100)  
declare @username varchar(100)  
open curname  
fetch next from curname into @procname, @username  
while @@fetch_status = 0  
begin  
declare @sql varchar(300)  
set @sql = 'grant execute on ' + @username + '.[' + @procname + '] to Execute_Storedprocedure'  
exec(@sql)  
fetch next from curname into @procname, @username  
end  
close curname  
deallocate curname  
  
GO

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating