GRANT Server Permissions (Transact-SQL)
Grants permissions on a server.
GRANT permission [ ,...n ]
TO <grantee_principal> [ ,...n ] [ WITH GRANT OPTION ]
[ AS <grantor_principal> ]
<grantee_principal> ::= SQL_Server_login
| SQL_Server_login_mapped_to_Windows_login
| SQL_Server_login_mapped_to_Windows_group
| SQL_Server_login_mapped_to_certificate
| SQL_Server_login_mapped_to_asymmetric_key
| server_role
<grantor_principal> ::= SQL_Server_login
| SQL_Server_login_mapped_to_Windows_login
| SQL_Server_login_mapped_to_Windows_group
| SQL_Server_login_mapped_to_certificate
| SQL_Server_login_mapped_to_asymmetric_key
| server_role
Permissions at the server scope can be granted only when the current database is master.
Information about server permissions can be viewed in the sys.server_permissions catalog view, and information about server principals can be viewed in the sys.server_principals catalog view. Information about membership of server roles can be viewd in the sys.server_role_members catalog view.
A server is the highest level of the permissions hierarchy. The most specific and limited permissions that can be granted on a server are listed in the following table.
|
Server permission |
Implied by server permission |
|---|---|
|
ADMINISTER BULK OPERATIONS |
CONTROL SERVER |
|
ALTER ANY AVAILABILITY GROUP |
CONTROL SERVER |
|
ALTER ANY CONNECTION |
CONTROL SERVER |
|
ALTER ANY CREDENTIAL |
CONTROL SERVER |
|
ALTER ANY DATABASE |
CONTROL SERVER |
|
ALTER ANY ENDPOINT |
CONTROL SERVER |
|
ALTER ANY EVENT NOTIFICATION |
CONTROL SERVER |
|
ALTER ANY EVENT SESSION |
CONTROL SERVER |
|
ALTER ANY LINKED SERVER |
CONTROL SERVER |
|
ALTER ANY LOGIN |
CONTROL SERVER |
|
ALTER ANY SERVER AUDIT |
CONTROL SERVER |
|
ALTER ANY SERVER ROLE |
CONTROL SERVER |
|
ALTER RESOURCES |
CONTROL SERVER |
|
ALTER SERVER STATE |
CONTROL SERVER |
|
ALTER SETTINGS |
CONTROL SERVER |
|
ALTER TRACE |
CONTROL SERVER |
|
AUTHENTICATE SERVER |
CONTROL SERVER |
|
CONNECT SQL |
CONTROL SERVER |
|
CONTROL SERVER |
CONTROL SERVER |
|
CREATE ANY DATABASE |
ALTER ANY DATABASE |
|
CREATE AVAILABILITY GROUP |
ALTER ANY AVAILABILITY GROUP |
|
CREATE DDL EVENT NOTIFICATION |
ALTER ANY EVENT NOTIFICATION |
|
CREATE ENDPOINT |
ALTER ANY ENDPOINT |
|
CREATE SERVER ROLE |
ALTER ANY SERVER ROLE |
|
CREATE TRACE EVENT NOTIFICATION |
ALTER ANY EVENT NOTIFICATION |
|
EXTERNAL ACCESS ASSEMBLY |
CONTROL SERVER |
|
SHUTDOWN |
CONTROL SERVER |
|
UNSAFE ASSEMBLY |
CONTROL SERVER |
|
VIEW ANY DATABASE |
VIEW ANY DEFINITION |
|
VIEW ANY DEFINITION |
CONTROL SERVER |
|
VIEW SERVER STATE |
ALTER SERVER STATE |
The grantor (or the principal specified with the AS option) must have either the permission itself with GRANT OPTION or a higher permission that implies the permission being granted. Members of the sysadmin fixed server role can grant any permission.
A. Granting a permission to a login
The following example grants CONTROL SERVER permission to the SQL Server login TerryEminhizer.
USE master;
GRANT CONTROL SERVER TO TerryEminhizer;
GO
B. Granting a permission that has GRANT permission
The following example grants ALTER ANY EVENT NOTIFICATION to SQL Server login JanethEsteves with the right to grant that permission to another login.
USE master;
GRANT ALTER ANY EVENT NOTIFICATION TO JanethEsteves WITH GRANT OPTION;
GO
C. Granting a permission to a server role
The following example creates two server roles named ITDevAdmin and ITDevelopers. It grants the ALTER ANY DATABASE permission to the ITDevAdmin user-defined server role including the WITH GRANT option so that the ITDevAdmin server role can reassign the ALTER ANY DATABASE permission. Then, the example grants the ITDevelopers the permission to use the ALTER ANY DATABASE permission of the ITDevAdmin server role.
USE master;
CREATE SERVER ROLE ITDevAdmin ;
CREATE SERVER ROLE ITDevelopers ;
GRANT ALTER ANY DATABASE TO ITDevAdmin WITH GRANT OPTION ;
GRANT ALTER ANY DATABASE TO ITDevelopers AS ITDevAdmin ;
GO
浙公网安备 33010602011771号