Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Grant Exec Rights on all Functions


Grant Exec Rights on all Functions

Author
Message
Sarab_SQLGeek
Sarab_SQLGeek
Old Hand
Old Hand (372 reputation)Old Hand (372 reputation)Old Hand (372 reputation)Old Hand (372 reputation)Old Hand (372 reputation)Old Hand (372 reputation)Old Hand (372 reputation)Old Hand (372 reputation)

Group: General Forum Members
Points: 372 Visits: 558
Dear All,

How to provide exec rights to a specific user on all User & System functions?

Regards,
Sarabpreet Singh Cool
Sarabpreet.com
SQLChamp.com
Twitter: @Sarab_SQLGeek
K. Brian Kelley
K. Brian Kelley
Keeper of the Duck
Keeper of the Duck (6.8K reputation)

Group: Moderators
Points: 6774 Visits: 1911
You should always try to grant permissions to a role you've created and then put the appropriate users in that role. If you also want the role to have execute rights on all stored procedures as well, you can simply:

GRANT EXECUTE ON SCHEMA::dbo



Assuming all are in the dbo schema. If you only want functions, the best thing to do is use a query to build the permissions T-SQL for you:

SELECT 'GRANT EXECUTE ON [' + SCHEMA_NAME(schema_id) + '].[' + [name] + '] TO MyRole;'
FROM sys.objects
WHERE type = 'FN';



Then take the code you've generated and execute it.

K. Brian Kelley
@‌kbriankelley
Sarab_SQLGeek
Sarab_SQLGeek
Old Hand
Old Hand (372 reputation)Old Hand (372 reputation)Old Hand (372 reputation)Old Hand (372 reputation)Old Hand (372 reputation)Old Hand (372 reputation)Old Hand (372 reputation)Old Hand (372 reputation)

Group: General Forum Members
Points: 372 Visits: 558
K. Brian Kelley (10/3/2009)
You should always try to grant permissions to a role you've created and then put the appropriate users in that role. If you also want the role to have execute rights on all stored procedures as well, you can simply:

I know its a best practice, thanks. i'll do the same from now onwards.

and thanks for the help Sir [Smile]

Regards,
Sarabpreet Singh Cool
Sarabpreet.com
SQLChamp.com
Twitter: @Sarab_SQLGeek
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