T-SQL Tutorial

T-SQL Revoke


This article shows how to revoke privileges, roles or permissions on SQL Server database objects.
The T-SQL statement REVOKE is used to revoke permissions in a database.
Rights such as create, alter, drop, insert, update, delete on a table can be revoked to a specific user using the revoke statement.



Revoke syntax

REVOKE SELECT ON table_name TO user_name;
REVOKE SELECT ON view_name TO user_name;
REVOKE EXECUTE ON OBJECT::procedure_name TO user_name;
REVOKE SELECT ON SCHEMA::schema_name TO user_name;


Revoke example

GO
REVOKE SELECT courses_view TO test_user;
REVOKE SELECT, INSERT, UPDATE, DELETE ON books TO test_user;
REVOKE SELECT ON SCHEMA::test_schema TO test_user;
REVOKE EXECUTE ON OBJECT::CourseSales TO test_user;
GO