News:

GinGly.com - Used by 85,000 Members - SMS Backed up 7,35,000 - Contacts Stored  28,850 !!

Main Menu

SQL Server Architecture (SQL Server 2000)

Started by sukishan, Aug 18, 2009, 06:38 PM

Previous topic - Next topic

sukishan

SQL Server Architecture (SQL Server 2000)
Rules
Rules
Rules are a backward-compatibility feature that perform some of the same functions as CHECK constraints. CHECK constraints are the preferred, standard way to restrict the values in a column. CHECK constraints are also more concise than rules; there can only be one rule applied to a column, but multiple CHECK constraints can be applied. CHECK constraints are specified as part of the CREATE TABLE statement, while rules are created as separate objects and then bound to the column.

This example creates a rule that performs the same function as the CHECK constraint example in the preceding topic. The CHECK constraint is the preferred method to use in Microsoft® SQL Server™ 2000.

CREATE RULE id_chk AS @id BETWEEN 0 and 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'
A good beginning makes a good ending