Database SQL Server rules creation, viewing, modification, binding and loosening of rules, deleting

Source: Internet
Author: User

Creating a rule with the CREATE RULE statement

Create a hire date rule hire_date_rule

CREATE RULE
as @hire_date >= ' 1980-01-01 ' and
@hire_date <= getdate ()

Create a gender rule sex_rule

CREATE RULE
as @sex inch (' male ',' female ')

Create scoring rules Grade_rule

CREATE RULE Grade_rule  as @value between 1  and  -

Create a character rule my_character_rule

Create Rule My_character_rule  as @value  like ' [a-z]%[0-9] '

Sp_helptext viewing rules

View text information for a rule hire_date_rule

EXECUTE sp_helptext hire_date_rule

Sp_bindrule binding Rules

Bind the rule hire_date_rule to the hire_date column of the employee table

EXEC ' employee.hire_date '

Define user-defined data type Pat_char, bind rule my_character_rule to Pat_var

EXEC sp_addtype pat_char,'varchar (TEN)','notNULL'  GOEXEC'futureonly '

Sp_unbindrule Unbind a rule

Unbind rules on the hire_date column and user-defined data type Pat_char on the employee table

EXEC ' employee.hire_date '

Drop RULE statement deletes one or more rules in the current database

DROP RULE

Database SQL Server rules creation, viewing, modification, binding and loosening of rules, deleting

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.