![]() |
Database »
Database »
General
Intermediate
Grant Execute on all procedures to a userBy Sumit Amar .This stored procedure grants execute privilege on all procedures to specified user |
C++, SQLWin2K, Visual Studio, SQL 2000, DBA, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
Granting execute privileges on all procedures to a restricted user, can be an issue. However, by retrieving the meta data information from the sysobjects, a simple loop can emulate this process and grant the execute on all available procedures to a specified user.
CREATE PROC grants as
declare curse cursor for select name from sysobjects where type='P'
OPEN CURSE
declare @proc varchar(100)
declare @stmt nvarchar(200)
fetch next from curse into @proc
while @@fetch_status=0
begin
set @stmt='grant execute on '+@proc+' to bnbuser'
exec SP_EXECUTESQL @STMT
print @stmt
fetch next from curse into @proc
end
close curse
deallocate curse
GO
After the compilation, just write grants in the query analyser to automate the grant process.
| You must Sign In to use this message board. | |||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 14 Jan 2004 Editor: Nishant Sivakumar |
Copyright 2004 by Sumit Amar . Everything else Copyright © CodeProject, 1999-2009 Web10 | Advertise on the Code Project |