Rules
A rule is a backward compatible feature that is used to execute functions that are the same as check constraints. Check constraints are the first standard method to limit column values. Check constraints are more concise than rules. A column can only apply one rule, but multiple check constraints can be applied. The check constraint is specified as part of the create table statement, and the rule is created as a separate object and then bound to the column.
In the following example, create a rule and perform the same functions as the check constraint example in the previous topic. Microsoft? SQL Server? 2000 the preferred method is the check constraint.
Create rule id_chk as @ ID between 0 & 10000
Go
Create Table cust_sample
(
Cust_id int
Primary Key,
Cust_name char (50 ),
Cust_address char (50 ),
Cust_credit_limit money,
)
Go
Sp_bindrule id_chk, 'cust _ sample. cust_id'
Go
Sp_bindrule
Bind a rule to a column or user-defined data type.
# Database Technology