Difference between Rule and Check Constraint

Check Constraint:

Check constraint is associated with columns in a Table. So these can't be re-used.

Suppose if "Emp" table having the coulmn "Salary" then
alter table Emp add constraint ck_op Check (Salary between 15000 and 45000)

Rule:

Rules are defined with in a database and can be applied to any number of columns.
Creating Rule:
CREATE RULE SAL_RANGE
as
@Sal > 15000 and @Sal > 45000
Binding Rule to a Column:
SP_BINDRULE 'SAL_RANGE','Emp.Salary'


2 comments:

Anonymous said...

Good and useful Info, thanks

Anonymous said...

thank you 4 the info!! it saves time!!