Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k points)

Does the following command effectively give the user, "MyUser," permission to execute ALL stored procedures in the database?

GRANT EXECUTE TO [MyDomain\MyUser]

1 Answer

0 votes
by (40.7k points)

For SQL Server 2008 and Above version, you can use the below code:

/* TO CREATE A NEW ROLE */

CREATE ROLE db_executor

/* TO GRANT EXECUTE TO THE ROLE */

GRANT EXECUTE TO db_executor

For the user (not a role), you can use the below code:

USE [DBName]

GO

GRANT EXECUTE TO [user]

...