Collections:
"GRANT EXECUTE" Statements - Granting EXECUTE permission in SQL Server
How to grant a permission using "GRANT EXECUTE" statements in SQL Server?
✍: FYIcenter.com
This is the fourth tutorial of a quick lesson on creating login and configure users for databases with Transact-SQL statements. Granting a user access to a database involves three steps. First, you create a login. The login lets the user connect to the SQL Server Database Engine. Then you configure the login as a user in the specified database. And finally, you grant that user permission to database objects. This lesson shows you these three steps, and shows you how to create a view and a stored procedure as the object. This tutorial assumes that you are running SQL Server Management Studio Express.
As an administrator, you can execute the SELECT from the Products table and the vw_Names view, and execute the pr_Names procedure; however, Mary cannot. To grant Mary the necessary permissions, use the GRANT statement.
Procedure Title - Execute the following statement to give Mary the EXECUTE permission for the pr_Names stored procedure.
GRANT EXECUTE ON pr_Names TO Mary; GO
In this scenario, Mary can only access the Products table by using the stored procedure. If you want Mary to be able to execute a SELECT statement against the view, then you must also execute GRANT SELECT ON vw_Names TO Mary. To remove access to database objects, use the REVOKE statement.
Note: If the table, the view, and the stored procedure are not owned by the same schema, granting permissions becomes more complex. For information about how to configure permissions on objects with different owners, see Ownership Chains.
About GRANT You must have EXECUTE permission to execute a stored procedure. You must have SELECT, INSERT, UPDATE, and DELETE permissions to access and change data. The GRANT statement is also used for other permissions, such as permission to create tables.
⇒ "DROP" Statements - Deleting database objects in SQL Server
⇐ "CREATE VIEW/PROCEDURE" Statements - Creating a View and a Stored Procedure in SQL Server
⇑ Getting Started with Transact-SQL Statements in SQL Server
2016-11-27, 2681🔥, 0💬
Popular Posts:
Collections: Interview Questions MySQL Tutorials MySQL Functions Oracle Tutorials SQL Server Tutoria...
What Happens to Your Transactions When ERROR 1205 Occurred in MySQL? If your transaction receives th...
What is sqlservr.exe - Process - SQL Server (SQLEX?PRESS) in SQL Server? Process sqlservr.exe is the...
What Happens If the UPDATE Subquery Returns Multiple Rows in SQL Server? If a subquery is used in a ...
How To Round a Numeric Value To a Specific Precision in SQL Server Transact-SQL? Sometimes you need ...