Skip to content

Latest commit

 

History

History
87 lines (61 loc) · 3.55 KB

drop-rule-transact-sql.md

File metadata and controls

87 lines (61 loc) · 3.55 KB
title description author ms.author ms.reviewer ms.date ms.service ms.subservice ms.topic f1_keywords helpviewer_keywords dev_langs
DROP RULE (Transact-SQL)
DROP RULE removes one or more user-defined rules from the current database.
WilliamDAssafMSFT
wiassaf
randolphwest
05/16/2024
sql
t-sql
reference
DROP_RULE_TSQL
DROP RULE
rules [SQL Server], removing
deleting roles
DROP RULE statement
removing roles
dropping roles
TSQL

DROP RULE (Transact-SQL)

[!INCLUDE SQL Server]

Removes one or more user-defined rules from the current database.

Important

DROP RULE will be removed in a future version of [!INCLUDE ssNoVersion]. 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 or ALTER TABLE. For more information, see Unique Constraints and Check Constraints.

:::image type="icon" source="../../includes/media/topic-link-icon.svg" border="false"::: Transact-SQL syntax conventions

Syntax

DROP RULE [ IF EXISTS ] { [ schema_name . ] rule_name } [ , ...n ]
[ ; ]

[!INCLUDE sql-server-tsql-previous-offline-documentation]

Arguments

IF EXISTS

Applies to: [!INCLUDE sssql16-md] and later versions

Conditionally drops the rule only if it already exists.

schema_name

The name of the schema to which the rule belongs.

rule

The rule to be removed. Rule names must comply with the rules for identifiers. Specifying the rule schema name is optional.

Remarks

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.

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.

The DROP RULE statement doesn't apply to CHECK constraints. For more information about dropping CHECK constraints, see ALTER TABLE.

Permissions

To execute DROP RULE, at a minimum, a user must have ALTER permission on the schema to which the rule belongs.

Examples

The following example unbinds and then drops the rule named VendorID_rule.

EXEC sp_unbindrule 'Production.ProductVendor.VendorID';
DROP RULE VendorID_rule;

Related content