DROP RULE (T-SQL)

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, 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.

Permissions

DROP RULE permission defaults to the rule owner and is not transferable. However, members of the db_owner fixed database role or 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
ALTER TABLE sp_help
CREATE RULE sp_helptext
USE sp_unbindrule
sp_bindrule  

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.