DENY (Transact-SQL)
Denies a permission to a principal. Prevents that principal from inheriting the permission through its group or role memberships.
The full syntax of the DENY statement is complex. The diagram above has been simplified to draw attention to its structure. Complete syntax for denying permissions on specific securables is described in the topics listed below.
DENY will fail if CASCADE is not specified when denying a permission to a principal that was granted that permission with GRANT OPTION specified.
The sp_helprotect system stored procedure reports permissions on a database-level securable.
Caution |
|---|
A table-level DENY does not take precedence over a column-level GRANT. This inconsistency in the permissions hierarchy has been preserved for the sake of backward compatibility. It will be removed in a future release. |
Caution |
|---|
Denying CONTROL permission on a database implicitly denies CONNECT permission on the database. A principal that is denied CONTROL permission on a database will not be able to connect to that database. |
Caution |
|---|
Denying CONTROL SERVER permission implicitly denies CONNECT SQL permission on the server. A principal that is denied CONTROL SERVER permission on a server will not be able to connect to that server. |
The caller (or the principal specified with the AS option) must have either CONTROL permission on the securable, or a higher permission that implies CONTROL permission on the securable. If using the AS option, the specified principal must own the securable on which a permission is being denied.
Grantees of CONTROL SERVER permission, such as members of the sysadmin fixed server role, can deny any permission on any securable in the server. Grantees of CONTROL permission on the database, such as members of the db_owner fixed database role, can deny any permission on any securable in the database. Grantees of CONTROL permission on a schema can deny any permission on any object in the schema. If the AS clause is used, the specified principal must own the securable on which permissions are being denied.
The following table lists the securables and the topics that describe the securable-specific syntax.
Application Role | |
Assembly | |
Asymmetric Key | |
Certificate | |
Contract | |
Database | |
Endpoint | |
Full-text Catalog | |
Full-text Stoplist | |
Function | |
Login | |
Message Type | |
Object | |
Queue | |
Remote Service Binding | |
Role | |
Route | |
Schema | |
Server | |
Service | |
Stored Procedure | |
Symmetric Key | |
Synonym | |
System Objects | |
Table | |
Type | |
User | |
View | |
XML Schema Collection |