Skip to content

Commit 5936d02

Browse files
authored
Merge pull request #19175 from MicrosoftDocs/FromPublicRepo
Confirm merge from FromPublicRepo to master to sync with https://github.com/MicrosoftDocs/sql-docs (branch live)
2 parents bd934a8 + d673c78 commit 5936d02

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

docs/t-sql/statements/revoke-transact-sql.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,31 @@ The use of AS in this statement does not imply the ability to impersonate anothe
193193
|User|[REVOKE Database Principal Permissions (Transact-SQL)](../../t-sql/statements/revoke-database-principal-permissions-transact-sql.md)|
194194
|View|[REVOKE Object Permissions (Transact-SQL)](../../t-sql/statements/revoke-object-permissions-transact-sql.md)|
195195
|XML Schema Collection|[REVOKE XML Schema Collection Permissions (Transact-SQL)](../../t-sql/statements/revoke-xml-schema-collection-permissions-transact-sql.md)|
196+
197+
198+
## Examples
199+
200+
### A. Grant and revoke
201+
**APPLIES TO:** [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)], [!INCLUDE[ssSDS](../../includes/sssds-md.md)]
202+
203+
The following example creates a schema, a contained database user, and a new role on a user database. It adds the user to the role, grants SELECT permission on the schema to the role, and then removes (`REVOKE`) that permission to the role.
204+
205+
206+
```sql
207+
CREATE SCHEMA Sales;
208+
GO
209+
CREATE USER Joe without login;
210+
GO
211+
CREATE ROLE Vendors;
212+
GO
213+
ALTER ROLE Vendors ADD MEMBER Joe;
214+
GO
215+
GRANT SELECT ON SCHEMA :: Sales TO Vendors;
216+
GO
217+
REVOKE SELECT ON SCHEMA :: Sales TO Vendors;
218+
GO
219+
220+
```
196221

197222
## See Also
198223
[Permissions Hierarchy (Database Engine)](../../relational-databases/security/permissions-hierarchy-database-engine.md)

0 commit comments

Comments
 (0)