SQL Server rule usage

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.