Share via


DENY Server Principal Permissions (Transact-SQL)

Denies permissions granted on a SQL Server login.

Topic link iconTransact-SQL Syntax Conventions

Syntax

DENY permission [ ,...n ] } 
    ON LOGIN :: SQL_Server_login
    TO <server_principal> [ ,...n ]
    [ CASCADE ]
    [ 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   

Arguments

  • permission
    Specifies a permission that can be denies on a SQL Server login. For a list of the permissions, see the Remarks section later in this topic.
  • LOGIN :: SQL_Server_login
    Specifies the SQL Server login on which the permission is being denied. The scope qualifier (::) is required.
  • TO SQL_Server_login
    Specifies the SQL Server login to which the permission is being denied.
  • 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.
  • CASCADE
    Indicates that the permission being denied is also denied to other principals to which it has been granted by this principal.
  • AS SQL_Server_login
    Specifies the SQL Server login from which the principal executing this query derives its right to deny the permission.

Remarks

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

Information about server permissions is visible in the sys.server_permissions catalog view. Information about server principals is visible in the sys.server_principals catalog view.

The DENY statement will fail if CASCADE is not specified when you are denying a permission to a principal that was granted that permission with GRANT OPTION.

A SQL Server login is a server-level securable. The most specific and limited permissions that can be denied on a SQL Server login are listed in the following table, together with the more general permissions that include them by implication.

SQL Server login permission Implied by SQL Server login permission Implied by server permission

CONTROL

CONTROL

CONTROL SERVER

IMPERSONATE

CONTROL

CONTROL SERVER

VIEW DEFINITION

CONTROL

VIEW ANY DEFINITION

ALTER

CONTROL

ALTER ANY LOGIN

Permissions

Requires CONTROL permission on the login or ALTER ANY LOGIN permission on the server.

Examples

A. Denying IMPERSONATE permission on a login

The following example denies IMPERSONATE permission on the SQL Server login WanidaBenshoof to a SQL Server login created from the Windows user AdvWorks\YoonM.

USE master;
DENY IMPERSONATE ON LOGIN::WanidaBenshoof TO [AdvWorks\YoonM];
GO

B. Denying VIEW DEFINITION permission with CASCADE

The following example denies VIEW DEFINITION permission on the SQL Server login EricKurjan to SQL Server login RMeyyappan. The CASCADE option indicates that VIEW DEFINITION permission on EricKurjan will also be denied to principals to which RMeyyappan granted this permission.

USE master;
DENY VIEW DEFINITION ON LOGIN::EricKurjan TO RMeyyappan 
    CASCADE;
GO 

See Also

Reference

sys.server_principals (Transact-SQL)
sys.server_permissions (Transact-SQL)
GRANT Server Principal Permissions (Transact-SQL)
REVOKE Server Principal Permissions (Transact-SQL)
CREATE LOGIN (Transact-SQL)

Other Resources

Principals
Permissions

Help and Information

Getting SQL Server 2005 Assistance