P.Brian.Mackey
P.Brian.Mackey

Reputation: 44275

Scripting execute permission along with stored procedure

In sql is it possible to script permissions as one can with the stored proc itself? So that I can simply tell somebody to hit execute and the proc and permissions just get created all at once.

Upvotes: 0

Views: 3638

Answers (1)

TLiebe
TLiebe

Reputation: 7986

Yes, you can script the execute permission as follows:

use [database_name]
GO
GRANT EXECUTE ON [dbo].[stored_procedure_name] TO [user_name]
GO

Replace the database_name, stored_procedure_name and user_name values with the appropriate values.

If you include this in your script after the SP CREATE statement it will add the permissions right after the SP is created.

Upvotes: 3

Related Questions