Book Image

SQL Server 2014 Development Essentials

By : Basit A. Masood-Al-Farooq
Book Image

SQL Server 2014 Development Essentials

By: Basit A. Masood-Al-Farooq

Overview of this book

Table of Contents (14 chapters)
SQL Server 2014 Development Essentials
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Grant, deny, and revoke permissions to securables


You can use SQL Server Management Studio or the T-SQL DCL statements to grant, revoke, and deny permissions to securables.

Grant, deny, and revoke permissions to securables with T-SQL DCL statements

In this section, we will use T-SQL DCL statements to grant, deny and revoke permissions.

Granting permissions to securables with T-SQL DCL statements

We use the GRANT keyword to grant permissions to securables. The basic syntax for the GRANT statement is as follows:

GRANT permission [,…n]
TO <grantee_principal> [,…n] [WITH GRANT OPTION]
[AS <grantor_principal>]

We use WITH GRANT OPTION when we want the user to grant the same permission to other logins.

For example, to grant Bob the SELECT permission WITH GRANT OPTION on the Book_Info table, you execute the following code:

USE [CH02_03];
GO

GRANT SELECT ON [dbo].[Book_Info] TO [Bob]
WITH GRANT OPTION;
GO

Denying permissions to securables with T-SQL DCL statements

We use the DENY keyword to prevent...