Re: Execute SP
From: Dan Guzman (guzmanda_at_nospam-online.sbcglobal.net)
Date: 12/23/04
- Previous message: vince.iacoboni_at_db.com: "Re: Kerberos authentication problems"
- In reply to: Eric Ward: "Execute SP"
- Next in thread: Jasper Smith: "Re: Execute SP"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Thu, 23 Dec 2004 07:43:49 -0600
If you need to grant EXECUTE to a role for a few number of procs, you can
execute GRANT statements for use EM:
GRANT EXEC ON MyProc TO MyProcExecuteRole
If you want to grant EXECUTE to a role for all procs in the database, you
can use a script like the one below:
SET NOCOUNT ON
DECLARE @GrantStatement nvarchar(4000)
DECLARE GrantStatements CURSOR
LOCAL FAST_FORWARD READ_ONLY FOR
SELECT
N'GRANT EXECUTE ON ' +
QUOTENAME(ROUTINE_SCHEMA) +
N'.' +
QUOTENAME(ROUTINE_NAME) +
N' TO MyProcExecuteRole'
FROM INFORMATION_SCHEMA.ROUTINES
WHERE
OBJECTPROPERTY(
OBJECT_ID(QUOTENAME(ROUTINE_SCHEMA) +
N'.' +
QUOTENAME(ROUTINE_NAME)),
'IsMSShipped') = 0 AND
OBJECTPROPERTY(
OBJECT_ID(QUOTENAME(ROUTINE_SCHEMA) +
N'.' +
QUOTENAME(ROUTINE_NAME)),
'IsProcedure') = 1
OPEN GrantStatements
WHILE 1 = 1
BEGIN
FETCH NEXT FROM GrantStatements
INTO @GrantStatement
IF @@FETCH_STATUS = -1 BREAK
BEGIN
RAISERROR (@GrantStatement, 0, 1) WITH NOWAIT
EXECUTE sp_ExecuteSQL @GrantStatement
END
END
CLOSE GrantStatements
DEALLOCATE GrantStatements
-- Hope this helps. Dan Guzman SQL Server MVP "Eric Ward" <EricWard@discussions.microsoft.com> wrote in message news:74243249-0388-410B-A306-9248A1A60C79@microsoft.com... > How do I give a roles access to execute a SP? > > Let me clarify: > I know that I can create a role and then go give that role Execute > permission to all the SP. > > I wondering if there is an easier way? > >
- Previous message: vince.iacoboni_at_db.com: "Re: Kerberos authentication problems"
- In reply to: Eric Ward: "Execute SP"
- Next in thread: Jasper Smith: "Re: Execute SP"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|