70-465 · Question #118
Your company has a SQL Azure subscription. You implement a database named Database1. Database1 has two tables named Table1 and Table2. You create a stored procedure named sp1. Sp1 reads data from…
The correct answer is D. Grant User1 the EXECUTE permission on sp1. To enable User1 to run the stored procedure sp1, the EXECUTE permission must be granted directly on sp1, which is the minimal necessary permission.
Question
Options
- AGrant User1 the INSERT permission on Table2.
- BAdd User1 to the db_datawriter role.
- CChange sp1 to run as the sa user.
- DGrant User1 the EXECUTE permission on sp1.
How the community answered
(25 responses)- A8% (2)
- B12% (3)
- C4% (1)
- D76% (19)
Why each option
To enable User1 to run the stored procedure sp1, the `EXECUTE` permission must be granted directly on sp1, which is the minimal necessary permission.
Granting `INSERT` permission on `Table2` alone would not allow User1 to execute `sp1`; it would only address a potential underlying permission issue if `sp1` were already runnable by User1 and executed under User1's context.
Adding User1 to the `db_datawriter` role is overly broad, granting INSERT, UPDATE, and DELETE permissions on all user tables, which violates the requirement to minimize permissions and does not directly grant `EXECUTE` permission on stored procedures.
Changing `sp1` to run as the `sa` user is a significant security risk, granting the procedure excessive privileges, and does not directly address how to grant User1 the ability to execute the procedure itself.
To execute any stored procedure in SQL Azure (and SQL Server), a user must be explicitly granted the `EXECUTE` permission on that specific procedure. Granting `EXECUTE` on `sp1` directly addresses the problem of User1 being "unable to run sp1" and adheres to the principle of least privilege by assigning only the required permission for procedure invocation.
Concept tested: SQL Stored Procedure EXECUTE Permission
Source: https://learn.microsoft.com/en-us/sql/t-sql/statements/grant-object-permissions-transact-sql?view=sql-server-ver16#EXECUTE-permissions
Topics
Community Discussion
No community discussion yet for this question.