GRANT Availability Group Permissions (Transact-SQL)

 

THIS TOPIC APPLIES TO: yesSQL Server (starting with 2012)noAzure SQL DatabasenoAzure SQL Data Warehouse noParallel Data Warehouse

Grants permissions on an Always On availability group.

Applies to: SQL Server (SQL Server 2012 through current version).

Topic link icon Transact-SQL Syntax Conventions

  
GRANT permission  [ ,...n ] ON AVAILABILITY GROUP :: availability_group_name  
        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  

permission
Specifies a permission that can be granted on an availability group. For a list of the permissions, see the Remarks section later in this topic.

ON AVAILABILITY GROUP ::availability_group_name
Specifies the availability group on which the permission is being granted. The scope qualifier (::) is required.

TO <server_principal>
Specifies the SQL Server login to which the permission is being granted.

SQL_Server_login
Specifies the name of a SQL Server login.

SQL_Server_login_from_Windows_login
Specifies the name of a SQL Server login created from a Windows login.

SQL_Server_login_from_certificate
Specifies the name of a SQL Server login mapped to a certificate.

SQL_Server_login_from_AsymKey
Specifies the name of a SQL Server login mapped to an asymmetric key.

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 SQL Server login from which the principal executing this query derives its right to grant the permission.

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

Information about availability groups is visible in the sys.availability_groups (Transact-SQL) catalog view. Information about server permissions is visible in the sys.server_permissions catalog view, and information about server principals is visible in the sys.server_principals catalog view.

An availability group is a server-level securable. The most specific and limited permissions that can be granted on an availability group are listed in the following table, together with the more general permissions that include them by implication.

Availability group permissionImplied by availability group permissionImplied by server permission
ALTERCONTROLALTER ANY AVAILABILITY GROUP
CONNECTCONTROLCONTROL SERVER
CONTROLCONTROLCONTROL SERVER
TAKE OWNERSHIPCONTROLCONTROL SERVER
VIEW DEFINITIONCONTROLVIEW ANY DEFINITION

For a chart of all Database Engine permissions, see Database Engine Permission Poster.

Requires CONTROL permission on the availability group or ALTER ANY AVAILABILTIY GROUP permission on the server.

A. Granting VIEW DEFINITION permission on an availability group

The following example grants VIEW DEFINITION permission on availability group MyAg to SQL Server login ZArifin.

USE master;  
GRANT VIEW DEFINITION ON AVAILABILITY GROUP::MyAg TO ZArifin;  
GO  

B. Granting TAKE OWNERSHIP permission with the GRANT OPTION

The following example grants TAKE OWNERSHIP permission on availability group MyAg to SQL Server user PKomosinski with the GRANT OPTION.

USE master;  
GRANT TAKE OWNERSHIP ON AVAILABILITY GROUP::MyAg TO PKomosinski   
    WITH GRANT OPTION;  
GO  

C. Granting CONTROL permission on an availability group

The following example grants CONTROL permission on availability group MyAg to SQL Server user PKomosinski. CONTROL allows the login complete control of the availability group, even though they are not the owner of the availability group. To change the ownership, see ALTER AUTHORIZATION (Transact-SQL).

USE master;  
GRANT CONTROL ON AVAILABILITY GROUP::MyAg TO PKomosinski;  
GO  

REVOKE Availability Group Permissions (Transact-SQL)
DENY Availability Group Permissions (Transact-SQL)
CREATE AVAILABILITY GROUP (Transact-SQL)
sys.availability_groups (Transact-SQL)
AlwaysOn Availability Groups Catalog Views (Transact-SQL)
Permissions (Database Engine)
Principals (Database Engine)

Community Additions

ADD
Show: