Skip to content

Latest commit

 

History

History
141 lines (108 loc) · 6.71 KB

grant-server-principal-permissions-transact-sql.md

File metadata and controls

141 lines (108 loc) · 6.71 KB
title description author ms.author ms.date ms.service ms.subservice ms.topic helpviewer_keywords dev_langs
GRANT Server Principal Permissions (Transact-SQL)
GRANT Server Principal Permissions (Transact-SQL)
VanMSFT
vanto
08/10/2017
sql
t-sql
reference
impersonate [SQL Server], granting
granting permissions [SQL Server], logins
permissions [SQL Server], impersonate
permissions [SQL Server], logins
GRANT statement, impersonation
GRANT statement, logins
logins [SQL Server], granting access
granting permissions [SQL Server], impersonation
TSQL

GRANT Server Principal Permissions (Transact-SQL)

[!INCLUDE SQL Server]

Grants permissions on a [!INCLUDEssNoVersion] login.

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

GRANT permission [ ,...n ] }   
    ON   
    { [ LOGIN :: SQL_Server_login ]  
      | [ SERVER ROLE :: server_role ] }   
    TO <server_principal> [ ,...n ]  
    [ WITH GRANT OPTION ]  
    [ AS SQL_Server_login ]   
  
<server_principal> ::=   
    SQL_Server_login  
    | SQL_Server_login_from_Windows_login   
    | SQL_Server_login_from_certificate   
    | SQL_Server_login_from_AsymKey   
    | server_role  

Arguments

permission
Specifies a permission that can be granted on a [!INCLUDEssNoVersion] login. For a list of the permissions, see the Remarks section later in this topic.

LOGIN :: SQL_Server_login
Specifies the [!INCLUDEssNoVersion] login on which the permission is being granted. The scope qualifier (::) is required.

SERVER ROLE :: server_role
Specifies the user-defined server role on which the permission is being granted. The scope qualifier (::) is required.

TO <server_principal> Specifies the [!INCLUDEssNoVersion] login or server role to which the permission is being granted.

SQL_Server_login
Specifies the name of a [!INCLUDEssNoVersion] login.

SQL_Server_login_from_Windows_login
Specifies the name of a [!INCLUDEssNoVersion] login created from a Windows login.

SQL_Server_login_from_certificate
Specifies the name of a [!INCLUDEssNoVersion] login mapped to a certificate.

SQL_Server_login_from_AsymKey
Specifies the name of a [!INCLUDEssNoVersion] login mapped to an asymmetric key.

server_role
Specifies the name of a user-defined server role.

WITH GRANT OPTION
Indicates that the principal will also be given the ability to grant the specified permission to other principals.

AS SQL_Server_login
Specifies the [!INCLUDEssNoVersion] login from which the principal executing this query derives its right to grant the permission.

Remarks

Permissions at the server scope can be granted only when the current database is master.

Information about server permissions is visible in the sys.server_permissions catalog view. Information about server principals is visible in the sys.server_principals catalog view.

[!INCLUDEssNoVersion] logins and server roles are server-level securables. The most specific and limited permissions that can be granted on a [!INCLUDEssNoVersion] login or server role are listed in the following table, together with the more general permissions that include them by implication.

SQL Server login or server role permission Implied by SQL Server login or server role permission Implied by server permission
CONTROL CONTROL CONTROL SERVER
IMPERSONATE CONTROL CONTROL SERVER
VIEW DEFINITION CONTROL VIEW ANY DEFINITION
ALTER CONTROL ALTER ANY LOGIN

ALTER ANY SERVER ROLE

Permissions

For logins, requires CONTROL permission on the login or ALTER ANY LOGIN permission on the server.

For server roles, requires CONTROL permission on the server role or ALTER ANY SERVER ROLE permission on the server.

Examples

A. Granting IMPERSONATE permission on a login

The following example grants IMPERSONATE permission on the [!INCLUDEssNoVersion] login WanidaBenshoof to a [!INCLUDEssNoVersion] login created from the Windows user AdvWorks\YoonM.

USE master;  
GRANT IMPERSONATE ON LOGIN::WanidaBenshoof to [AdvWorks\YoonM];  
GO  

B. Granting VIEW DEFINITION permission with GRANT OPTION

The following example grants VIEW DEFINITION on the [!INCLUDEssNoVersion] login EricKurjan to the [!INCLUDEssNoVersion] login RMeyyappan with GRANT OPTION.

USE master;  
GRANT VIEW DEFINITION ON LOGIN::EricKurjan TO RMeyyappan   
    WITH GRANT OPTION;  
GO   

C. Granting VIEW DEFINITION permission on a server role

The following example grants VIEW DEFINITION on the Sales server role to the Auditors server role.

USE master;  
GRANT VIEW DEFINITION ON SERVER ROLE::Sales TO Auditors ;  
GO   

See Also

sys.server_principals (Transact-SQL)
sys.server_permissions (Transact-SQL)
CREATE LOGIN (Transact-SQL)
Principals (Database Engine)
Permissions (Database Engine)
Security Functions (Transact-SQL)
Security Stored Procedures (Transact-SQL)