5,557,686 members and growing! (15,077 online)
Email Password   helpLost your password?
Database » Database » General     Intermediate

Grant Execute on all procedures to a user

By Sumit Amar .

This stored procedure grants execute privilege on all procedures to specified user
C++, SQLWin2K, Windows, Visual Studio, SQL Server, SQL 2000, DBA, Dev

Posted: 14 Jan 2004
Updated: 14 Jan 2004
Views: 36,713
Bookmarked: 6 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
10 votes for this Article.
Popularity: 2.81 Rating: 2.81 out of 5
3 votes, 30.0%
1
1 vote, 10.0%
2
2 votes, 20.0%
3
0 votes, 0.0%
4
4 votes, 40.0%
5

Introduction

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Sumit Amar .


Sumit Amar started programming in BASIC at the age of 14 in 1993, then moved on to C/UNIX.
Later in 1999, he started developing commercial applications in J2SE, J2EE and Perl. He started developing applications in .NET with ASP+ (later renamed to ASP.NET) in December 2000 with public Beta 1. He's continuing development in .NET (ASP.NET, C#) ever since.

He has an MBA degree in IT and Systems besides his 200+ certifications including MCSD.NET, SCJP, MCTS, MCITP (Administrator and Developer), SCWCD, OCP-DBA and numerous Brainbench certifications (Transcript ID 2232802, World rank 3).

He is a Lead Software Development Engineer at Microsoft Corporation, Redmond WA, where he works majorly on AJAX, .NET, SOAP, Web Services and Secure applications.
Occupation: Web Developer
Location: United States United States

Other popular Database articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 3 of 3 (Total in Forum: 3) (Refresh)FirstPrevNext
Subject  Author Date 
General10xmemberarchimedes091:54 29 Aug '08  
GeneralThanksmembertoxaq17:15 4 Jul '07  
Generalgrant executesussAnonymous3:47 26 Aug '05  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 14 Jan 2004
Editor: Nishant Sivakumar
Copyright 2004 by Sumit Amar .
Everything else Copyright © CodeProject, 1999-2008
Web17 | Advertise on the Code Project