Rule Validation in SQL

24/05/2011 13:31

CREATE RULE id_chk AS @id BETWEEN 0 and 10000;
GO

CREATE RULE Address_chk AS @Address in ('1000','2000','3000')
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 Address_chk, 'cust_sample.cust_address';
GO

insert into cust_sample values(1005,'shankar','Chennai',22000)

insert into cust_sample values(1000,'shankar','Namakkal',22000)

select * from cust_sample