SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


grant permission to view/edit/execute all stored procedure


grant permission to view/edit/execute all stored procedure

Author
Message
sqlfriends
sqlfriends
Hall of Fame
Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)Hall of Fame (3.9K reputation)

Group: General Forum Members
Points: 3897 Visits: 4025
Is there a way to grant a user to alter, view and execute all the stored procedure in a database?

I have set him as a db_writer, but I don't think that includes above access?

Thanks
jyuan68
jyuan68
SSC Rookie
SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)SSC Rookie (44 reputation)

Group: General Forum Members
Points: 44 Visits: 91
You can use the code as follow which use cursor to grant permission.



declare @sp_name nvarchar(300)
declare @sql nvarchar(300)
declare cursor_name cursor
for select quotename(b.name)+'.'+ quotename(a.name)
from sys.objects a inner join sys.schemas b on a.schema_id=b.schema_id where type='p'
open cursor_name
fetch next from cursor_name into @sp_name
while @@fetch_status=0
begin
print @sp_name
set @sql=N'GRANT ALTER,execute,view definition ON '+@sp_name+' TO ***user***'
exec sp_executesql @sql

fetch next from cursor_name into @sp_name
end
close cursor_name
deallocate cursor_name


MyDoggieJessie
MyDoggieJessie
SSCertifiable
SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)SSCertifiable (6.7K reputation)

Group: General Forum Members
Points: 6724 Visits: 7394
Perhaps this may be simpler:
use [YourDB]
GO
GRANT ALTER, EXECUTE, VIEW DEFINITION TO [DOMAIN\User]
GO



______________________________________________________________________________
"Never argue with an idiot; They'll drag you down to their level and beat you with experience" ;-)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search