DROP RULE

Transact-SQL Reference

Transact-SQL Reference

DROP RULE

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

Syntax

DROP RULE { rule } [ ,...n ]

Arguments

rule

Is the rule to be removed. Rule names must conform to the rules for identifiers. For more information about rules for identifiers, see Using Identifiers. Specifying the rule owner name is optional.

n

Is a placeholder indicating that multiple rules can be specified.

Remarks

To drop a rule, first unbind it if the rule is currently bound to a column or to a user-defined data type. Use sp_unbindrule to unbind the rule. If the rule is bound when attempting 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 rule's constraints. Existing data is not affected in any way.

The DROP RULE statement does not apply to CHECK constraints. For more information about dropping CHECK constraints, see "ALTER TABLE" in this volume.

Permissions

DROP RULE permissions default to the rule owner and are not transferable. However, members of the db_owner and db_ddladmin fixed database roles and the sysadmin fixed server role can drop any object by specifying the owner in DROP RULE.

Examples

This example unbinds and then drops the rule named pub_id_rule.

USE pubs
IF EXISTS (SELECT name FROM sysobjects
         WHERE name = 'pub_id_rule'
            AND type = 'R')
   BEGIN
      EXEC sp_unbindrule 'publishers.pub_id'
      DROP RULE pub_id_rule
   END
GO

See Also

CREATE RULE

sp_bindrule

sp_help

sp_helptext

sp_unbindrule

USE