Skip to content

Commit d673c78

Browse files
authored
Merge pull request #6329 from alberto-morillo/patch-2
Update revoke-transact-sql.md
2 parents 1a10c8e + 90e3ef2 commit d673c78

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)