GRANT Database Scoped Credential permissions (Transact-SQL)

Applies to: SQL Server 2017 (14.x) and later Azure SQL Database Azure SQL Managed Instance Azure Synapse Analytics

Grants permissions on a database scoped credential.

Transact-SQL syntax conventions

Syntax

GRANT permission  [ ,...n ]    
    ON DATABASE SCOPED CREDENTIAL :: credential_name   
    TO principal [ ,...n ] [ WITH GRANT OPTION ]   
    [ AS granting_principal ]   

Arguments

permission

Specifies a permission that can be granted on a database scoped credential. Listed below.

ON DATABASE SCOPED CREDENTIAL ::credential_name

Specifies the database scoped credential on which the permission is being granted. The scope qualifier "::" is required.

database_principal

Specifies the principal to which the permission is being granted. One of the following:

  • database user
  • database role
  • application role
  • database user mapped to a Windows login
  • database user mapped to a Windows group
  • database user mapped to a certificate
  • database user mapped to an asymmetric key
  • database user not mapped to a server principal.

GRANT OPTION

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

AS granting_principal

Specifies a principal from which the principal executing this query derives its right to grant the permission. One of the following:

  • database user
  • database role
  • application role
  • database user mapped to a Windows login
  • database user mapped to a Windows group
  • database user mapped to a certificate
  • database user mapped to an asymmetric key
  • database user not mapped to a server principal.

Remarks

A database scoped credential is a database-level securable contained by the database that is its parent in the permissions hierarchy. The most specific and limited permissions that can be granted on a database scoped credential are listed below, together with the more general permissions that include them by implication.

Database scoped credential permission Implied by database scoped credential permission Implied by database permission
CONTROL CONTROL CONTROL
TAKE OWNERSHIP CONTROL CONTROL
ALTER CONTROL CONTROL
REFERENCES CONTROL REFERENCES
VIEW DEFINITION CONTROL VIEW DEFINITION

Note

In Azure Synapse Analytics, GRANT on database scoped credential is supported for serverless SQL pools only.

Permissions

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.

If using the AS option, these additional requirements apply.

AS granting_principal Additional permission required
Database user IMPERSONATE permission on the user, membership in the db_securityadmin fixed database role, membership in the db_owner fixed database role, or membership in the sysadmin fixed server role.
Database user mapped to a Windows login IMPERSONATE permission on the user, membership in the db_securityadmin fixed database role, membership in the db_owner fixed database role, or membership in the sysadmin fixed server role.
Database user mapped to a Windows group Membership in the Windows group, membership in the db_securityadmin fixed database role, membership in the db_owner fixed database role, or membership in the sysadmin fixed server role.
Database user mapped to a certificate Membership in the db_securityadmin fixed database role, membership in the db_owner fixed database role, or membership in the sysadmin fixed server role.
Database user mapped to an asymmetric key Membership in the db_securityadmin fixed database role, membership in the db_owner fixed database role, or membership in the sysadmin fixed server role.
Database user not mapped to any server principal IMPERSONATE permission on the user, membership in the db_securityadmin fixed database role, membership in the db_owner fixed database role, or membership in the sysadmin fixed server role.
Database role ALTER permission on the role, membership in the db_securityadmin fixed database role, membership in the db_owner fixed database role, or membership in the sysadmin fixed server role.
Application role ALTER permission on the role, membership in the db_securityadmin fixed database role, membership in the db_owner fixed database role, or membership in the sysadmin fixed server role.

Object owners can grant permissions on the objects they own. Principals with CONTROL permission on a securable can grant permission on that securable.

Grantees of CONTROL SERVER permission, such as members of the sysadmin fixed server role, can grant any permission on any securable in the server. Grantees of CONTROL permission on a database, such as members of the db_owner fixed database role, can grant any permission on any securable in the database. Grantees of CONTROL permission on a schema can grant any permission on any object within the schema.

Next steps

GRANT (Transact-SQL)
REVOKE Database Scoped Credential (Transact-SQL)
DENY Database Scoped Credential (Transact-SQL)
Permissions (Database Engine)
Principals (Database Engine)
Encryption Hierarchy