Skip to content

Commit 6bff54d

Browse files
committed
Refresh DROP RULE article and include PR 9779
1 parent 3f48306 commit 6bff54d

1 file changed

Lines changed: 87 additions & 76 deletions

File tree

Lines changed: 87 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,87 @@
1-
---
2-
title: "DROP RULE (Transact-SQL)"
3-
description: DROP RULE (Transact-SQL)
4-
author: WilliamDAssafMSFT
5-
ms.author: wiassaf
6-
ms.date: "05/11/2017"
7-
ms.service: sql
8-
ms.subservice: t-sql
9-
ms.topic: reference
10-
f1_keywords:
11-
- "DROP_RULE_TSQL"
12-
- "DROP RULE"
13-
helpviewer_keywords:
14-
- "rules [SQL Server], removing"
15-
- "deleting roles"
16-
- "DROP RULE statement"
17-
- "removing roles"
18-
- "dropping roles"
19-
dev_langs:
20-
- "TSQL"
21-
---
22-
# DROP RULE (Transact-SQL)
23-
[!INCLUDE [SQL Server](../../includes/applies-to-version/sql-asdbmi.md)]
24-
25-
Removes one or more user-defined rules from the current database.
26-
27-
> [!IMPORTANT]
28-
> DROP RULE will be removed in the next version of [!INCLUDE[msCoName](../../includes/msconame-md.md)] [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)]. Do not use DROP RULE in new development work, and plan to modify applications that currently use them. Instead, use CHECK constraints that you can create by using the CHECK keyword of [CREATE TABLE](../../t-sql/statements/create-table-transact-sql.md) or [ALTER TABLE](../../t-sql/statements/alter-table-transact-sql.md). For more information, see [Unique Constraints and Check Constraints](../../relational-databases/tables/unique-constraints-and-check-constraints.md).
29-
30-
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: [Transact-SQL syntax conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
31-
32-
## Syntax
33-
34-
```syntaxsql
35-
DROP RULE [ IF EXISTS ] { [ schema_name . ] rule_name } [ ,...n ] [ ; ]
36-
```
37-
38-
[!INCLUDE[sql-server-tsql-previous-offline-documentation](../../includes/sql-server-tsql-previous-offline-documentation.md)]
39-
40-
## Arguments
41-
*IF EXISTS*
42-
**Applies to**: [!INCLUDE[ssNoVersion](../../includes/ssnoversion-md.md)] ( [!INCLUDE[sssql16-md](../../includes/sssql16-md.md)] through [current version](/troubleshoot/sql/general/determine-version-edition-update-level)).
43-
44-
Conditionally drops the rule only if it already exists.
45-
46-
*schema_name*
47-
Is the name of the schema to which the rule belongs.
48-
49-
*rule*
50-
Is the rule to be removed. Rule names must comply with the rules for [identifiers](../../relational-databases/databases/database-identifiers.md). Specifying the rule schema name is optional.
51-
52-
## Remarks
53-
To drop a rule, first unbind it if the rule is currently bound to a column or to an alias data type. To unbind the rule, use **sp_unbindrule**. If the rule is bound when you try to drop it, an error message is displayed and the DROP RULE statement is canceled.
54-
55-
After a rule is dropped, new data entered into the columns previously governed by the rule is entered without the constraints of the rule. Existing data is not affected in any way.
56-
57-
The DROP RULE statement does not apply to CHECK constraints. For more information about dropping CHECK constraints, see [ALTER TABLE (Transact-SQL)](../../t-sql/statements/alter-table-transact-sql.md).
58-
59-
## Permissions
60-
To execute DROP RULE, at a minimum, a user must have ALTER permission on the schema to which the rule belongs.
61-
62-
## Examples
63-
The following example unbinds and then drops the rule named `VendorID_rule`.
64-
65-
```sql
66-
EXEC sp_unbindrule 'Production.ProductVendor.VendorID'
67-
DROP RULE VendorID_rule
68-
```
69-
70-
## See Also
71-
[CREATE RULE (Transact-SQL)](../../t-sql/statements/create-rule-transact-sql.md)
72-
[sp_bindrule (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-bindrule-transact-sql.md)
73-
[sp_help (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-help-transact-sql.md)
74-
[sp_helptext (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-helptext-transact-sql.md)
75-
[sp_unbindrule (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-unbindrule-transact-sql.md)
76-
[USE (Transact-SQL)](../../t-sql/language-elements/use-transact-sql.md)
1+
---
2+
title: "DROP RULE (Transact-SQL)"
3+
description: DROP RULE removes one or more user-defined rules from the current database.
4+
author: WilliamDAssafMSFT
5+
ms.author: wiassaf
6+
ms.reviewer: randolphwest
7+
ms.date: 05/16/2024
8+
ms.service: sql
9+
ms.subservice: t-sql
10+
ms.topic: reference
11+
f1_keywords:
12+
- "DROP_RULE_TSQL"
13+
- "DROP RULE"
14+
helpviewer_keywords:
15+
- "rules [SQL Server], removing"
16+
- "deleting roles"
17+
- "DROP RULE statement"
18+
- "removing roles"
19+
- "dropping roles"
20+
dev_langs:
21+
- "TSQL"
22+
---
23+
# DROP RULE (Transact-SQL)
24+
25+
[!INCLUDE [SQL Server](../../includes/applies-to-version/sql-asdbmi.md)]
26+
27+
Removes one or more user-defined rules from the current database.
28+
29+
> [!IMPORTANT]
30+
> `DROP RULE` will be removed in a future version of [!INCLUDE [ssNoVersion](../../includes/ssnoversion-md.md)]. Don't use `DROP RULE` in new development work, and plan to modify applications that currently use them. Instead, use `CHECK` constraints that you can create by using the `CHECK` keyword of [CREATE TABLE](create-table-transact-sql.md) or [ALTER TABLE](alter-table-transact-sql.md). For more information, see [Unique Constraints and Check Constraints](../../relational-databases/tables/unique-constraints-and-check-constraints.md).
31+
32+
:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: [Transact-SQL syntax conventions](../../t-sql/language-elements/transact-sql-syntax-conventions-transact-sql.md)
33+
34+
## Syntax
35+
36+
```syntaxsql
37+
DROP RULE [ IF EXISTS ] { [ schema_name . ] rule_name } [ , ...n ]
38+
[ ; ]
39+
```
40+
41+
[!INCLUDE [sql-server-tsql-previous-offline-documentation](../../includes/sql-server-tsql-previous-offline-documentation.md)]
42+
43+
## Arguments
44+
45+
#### *IF EXISTS*
46+
47+
**Applies to**: [!INCLUDE [sssql16-md](../../includes/sssql16-md.md)] and later versions
48+
49+
Conditionally drops the rule only if it already exists.
50+
51+
#### *schema_name*
52+
53+
The name of the schema to which the rule belongs.
54+
55+
#### *rule*
56+
57+
The rule to be removed. Rule names must comply with the rules for [identifiers](../../relational-databases/databases/database-identifiers.md). Specifying the rule schema name is optional.
58+
59+
## Remarks
60+
61+
To drop a rule, first unbind it if the rule is currently bound to a column or to an alias data type. To unbind the rule, use `sp_unbindrule`. If the rule is bound when you try to drop it, an error message is displayed and the `DROP RULE` statement is canceled.
62+
63+
After a rule is dropped, new data entered into the columns previously governed by the rule is entered without the constraints of the rule. Existing data isn't affected in any way.
64+
65+
The `DROP RULE` statement doesn't apply to `CHECK` constraints. For more information about dropping `CHECK` constraints, see [ALTER TABLE](alter-table-transact-sql.md).
66+
67+
## Permissions
68+
69+
To execute `DROP RULE`, at a minimum, a user must have `ALTER` permission on the schema to which the rule belongs.
70+
71+
## Examples
72+
73+
The following example unbinds and then drops the rule named `VendorID_rule`.
74+
75+
```sql
76+
EXEC sp_unbindrule 'Production.ProductVendor.VendorID';
77+
DROP RULE VendorID_rule;
78+
```
79+
80+
## Related content
81+
82+
- [CREATE RULE (Transact-SQL)](create-rule-transact-sql.md)
83+
- [sp_bindrule (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-bindrule-transact-sql.md)
84+
- [sp_help (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-help-transact-sql.md)
85+
- [sp_helptext (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-helptext-transact-sql.md)
86+
- [sp_unbindrule (Transact-SQL)](../../relational-databases/system-stored-procedures/sp-unbindrule-transact-sql.md)
87+
- [USE (Transact-SQL)](../language-elements/use-transact-sql.md)

0 commit comments

Comments
 (0)