SSIS and Sql Server Journey

Personal Notes of Sarabjit Singh and Bhavpreet Singh

Grant Execute to Given User – Dynamic Query

on January 25, 2012

declare @username varchar(255)
set @username = ‘YourUser’
SELECT ‘grant exec on ‘ + QUOTENAME(ROUTINE_SCHEMA) + ‘.’ +
QUOTENAME(ROUTINE_NAME) + ‘ TO ‘ + @username FROM INFORMATION_SCHEMA.ROUTINES
WHERE OBJECTPROPERTY(OBJECT_ID(ROUTINE_NAME),’IsMSShipped’) = 0
and ROUTINE_TYPE=’PROCEDURE’

The above query with result in all the User Defined Stored Procedures with “Grant Execute Permissions.

Run the resulting commands and ‘YourUser’ has the Execute Rights 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: