Share via


Rule Object

この機能は、将来のバージョンの Microsoft SQL Server では削除される予定です。新規の開発作業ではこの機能を使用しないようにし、現在この機能を使用しているアプリケーションは修正することを検討してください。

The Rule object exposes the attributes of a single Microsoft SQL Server data-integrity rule.

現在のオブジェクトを表す SQL-DMO オブジェクト モデル

Properties

CreateDate Property

Owner Property (Database Objects)

ID Property

Text Property

Name Property

 

Methods

BindToColumn Method

Remove Method (Objects)

BindToDatatype Method

Script Method

ListBoundColumns Method

UnbindFromColumn Method

ListBoundDatatypes Method

UnbindFromDatatype Method

解説

SQL Server offers several mechanisms for ensuring data integrity. A SQL Server rule is a Transact-SQL condition_expression syntax element that defines a data-integrity constraint. A rule can be bound to a column or user-defined data type. The condition_expression syntax element is run to validate data for a single column when a value is inserted into the column bound by the rule. For more information, see CREATE RULE (Transact-SQL).

With the Rule object, you can:

  • Create a SQL Server rule that defines an integrity constraint.
  • Bind an existing SQL Server rule to a column or user-defined data type.
  • Remove the constraint from a column or user-defined data type by unbinding a SQL Server rule.
  • Remove a SQL Server rule definition from a SQL Server database.
  • Generate a Transact-SQL script to create the rule represented by the object.

The Name property of a Rule object uses the SQL Server data type sysname. The value of the Name property must be unique for a database.

After you create the rule, use the BindToColumn and BindToDatatype methods of the Rule object to apply the constraint to SQL Server columns and user-defined data types.

ms136197.note(ja-jp,SQL.90).gifメモ :
The Rule object is compatible with instances of SQL Server versions 7.0 and later. However, the Rule2 object extends the functionality of the Rule object for use with features that were introduced in SQL Server 2000.

To create a SQL Server rule

  1. Create a Rule object.

  2. Set the Name property.

  3. Set the Text property with the Transact-SQL script that validates data integrity for the columns bound by the rule.

  4. Add the Rule object to the Rules collection of a connected Database object.

To remove a rule from a SQL Server database

  1. Get the referring Rule object from the Rules collection of a connected Database object.

  2. Use the ListBoundColumns and ListBoundDatatypes methods to determine affected SQL Server columns and user-defined data types.

  3. Use the UnbindFromColumn and UnbindFromDatatype methods to remove the constraint from columns and user-defined data types bound by the rule.

  4. Use the Remove method of the Rule object to remove it from the SQL Server database.

参照

関連項目

Rule2 Object

ヘルプおよび情報

SQL Server 2005 の参考資料の入手