Creating a check constraint specifies a condition that any value must pass before it is inserted into the table.
A check constraint specifies a condition that any value must pass before it is
inserted into the table. You can create a check constraint at the table or column level.
Column-level check constraints reference a single column. Table-level check constraints
apply to the entire table.
- In the left pane of the Administration Console, expand , then choose one of the following:
- Click the Name field of the table, then click the drop-down arrow and select
Properties.
- In the left pane, click Check Constraint.
- Select New.
- On the Name screen, enter a name for the check constraint.
- On the Expression screen, enter an expression that defines the constraint.
For example,
salary > 0. The comparable command line syntax using
alter table is:
alter table sample.dbo.employee
add constraint test_const
CHECK (salary > 0)
- (Optional) Click Summary to review the check constraint
expression.
- Click Finish .