Compartir a través de


How to: Modify Check Constraints

You modify a check constraint when you want to change the constraint expression or the options that enable or disable the constraint for specific conditions. For information about how to define the correct syntax for a constraint, see How to: Define Check Constraint Expressions.

Note

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Customizing Development Settings in Visual Studio.

To modify a check constraint

  1. In your database diagram, right-click the table that contains the constraint, and then click Properties.

    -or-

    Open the Table Designer for the table that contains the constraint, right-click in the Table Designer, and click Check Constraints.

  2. Click the Check Constraints tab.

  3. In the Selected Check Constraint list, click the constraint that you want to change.

  4. Complete an action from the following table:

    Note

    Some databases have different functionality for check constraints.

    To

    Follow these steps

    Edit the constraint expression

    Type the new expression in the Expression field.

    Rename the constraint

    Type a new name in the Name field.

    Apply the constraint to existing data

    Select the Check Existing Data on Creation or Enabling check box.

    Disable the constraint when data is added to the table or updated in the table.

    Clear the Enforce Constraint for INSERTs and UPDATEs check box.

    Disable the constraint when a replication agent inserts or updates data in your table. For more information, see Controlling Constraints, Identities, and Triggers with NOT FOR REPLICATION.

    Clear the Enforce For Replication check box.

The constraint is updated in the database when you save your table or diagram.

See Also

Other Resources

Working with Constraints

Working with Keys