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