What are GRANT, DENY and REVOKE in SQL Server.


These are related to security in SQL Server.

GRANT – It is used to give access permission for any object in SQL Server.

GRANT SELECT ON OBJECT::SCHEMA.TABLE_NAME TO ROLE_NAME;


All the users with this ROLE_NAME can only select data from TABLE_NAME Table.
DENY –It is used to block access permission for any object in SQL Server.

DENY SELECT ON OBJECT::SCHEMA.TABLE_NAME TO ROLE_NAME;


All the users with this ROLE_NAME will not be able to select data from TABLE_NAME Table.
REVOKE –It is used to undo a permission whether it is GRANT or DENY in SQL Server.

REVOKE SELECT ON OBJECT::SCHEMA.TABLE_NAME FROM ROLE_NAME;


All the users with this ROLE_NAME will GRANT permission if they were previously DENY. And those GRANT permission previously will DENY.