Skip to content

DENY

The following SQL code demonstrates the usage of the DENY command in SQL Server:

DENY SELECT, INSERT, UPDATE, DELETE ON OBJECT::dbo.Person TO user1;

The SQL Server Management Studio will not display any output for the above command as this command is only executed internally to change permissions. The output can be confirmed by attempting to execute any select, insert, update, or delete operations with the ‘user1’ user.

The DENY command is used to deny permissions to a user in SQL Server. It revokes specified permissions to a certain database object from a user or role. In the above example, DENY is used to revoke ‘SELECT’, ‘INSERT’, ‘UPDATE’, ‘DELETE’ permissions on the Person table in the dbo schema from ‘user1’. After this command is executed and committed, ‘user1’ will not be able to select, insert, update, or delete any data in the Person table.