GRANT XML Schema Collection Permissions (Transact-SQL)
Grants permissions on an XML schema collection.
GRANT permission [ ,...n ] ON
XML SCHEMA COLLECTION :: [ schema_name . ]
XML_schema_collection_name
TO <database_principal> [ ,...n ]
[ WITH GRANT OPTION ]
[ AS <database_principal> ]
<database_principal> ::=
Database_user
| Database_role
| Application_role
| Database_user_mapped_to_Windows_User
| Database_user_mapped_to_Windows_Group
| Database_user_mapped_to_certificate
| Database_user_mapped_to_asymmetric_key
| Database_user_with_no_login
Information about XML schema collections is visible in the sys.xml_schema_collections catalog view.
An XML schema collection is a schema-level securable contained by the schema that is its parent in the permissions hierarchy. The most specific and limited permissions that can be granted on an XML schema collection are listed in the following table, together with the more general permissions that include them by implication.
XML schema collection permission | Implied by XML schema collection permission | Implied by schema permission |
|---|---|---|
ALTER | CONTROL | ALTER |
CONTROL | CONTROL | CONTROL |
EXECUTE | CONTROL | EXECUTE |
REFERENCES | CONTROL | REFERENCES |
TAKE OWNERSHIP | CONTROL | CONTROL |
VIEW DEFINITION | CONTROL | VIEW DEFINITION |
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 you are using the AS option, the following additional requirements apply.
AS | 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. |
The following example grants EXECUTE permission on the XML schema collection Invoices4 to the user Wanida. The XML schema collection Invoices4 is located inside the Sales schema of the AdventureWorks2008R2 database.
USE AdventureWorks2008R2;
GRANT EXECUTE ON XML SCHEMA COLLECTION::Sales.Invoices4 TO Wanida;
GO