다음을 통해 공유


Rules Collection

Microsoft SQL Server의 이후 버전에서는 이 기능이 제거됩니다. 새 개발 작업에서는 이 기능을 사용하지 말고, 현재 이 기능을 사용하는 응용 프로그램은 수정하십시오.

The Rules collection contains Rule objects that reference Microsoft SQL Server data integrity constraints implemented as database Rule objects.

현재 개체를 보여 주는 SQL-DMO 개체 모델

Properties

Count Property

Methods

Add Method

Refresh Method

Item Method

Remove Method (Collections)

ItemByID Method

 

주의

With the Rules collection, you can:

  • Create SQL Server integrity constraints implemented as rules.
  • Remove a rule definition from an instance of SQL Server.

For more information about creating SQL Server rules, see Rule Object.

To remove a SQL Server data integrity constraint implemented as a rule

  1. Get the Rule object that references the targeted constraint from the Rules collection using the Item or ItemByID method. When extracting a Rule object using the name of the referenced rule, use the owner name to qualify the rule name, as in:

    Set oRule = oDatabase.Rules("Rule_RowIDs", "dbo")
    
  2. Use the ListBoundColumns and ListBoundDatatypes methods of the Rule object to report affected columns or user-defined data types. If either method returns items, use the UnbindFromColumn or UnbindFromDatatype methods to resolve dependencies.

  3. Use the Remove method of the Rule object to remove the targeted constraint.

When using the Item method, the Rules collection supports member identification using either name or ordinal reference syntax. Additionally, when using the rule name to select an object from the collection, the Item method allows owner name qualification of the targeted SQL Server constraint. For example:

Set oRule = oDatabase.Rules("Rule_RowIDs", "stevenb")

Or:

Set oRule = oDatabase.Rules(2)

The Remove method of the Rules collection supports member targeting using either the rule name or the ordinal position of the object in the collection. The Remove method does not support rule owner name qualification when using the method to drop a constraint. When using the Rules collection to remove a SQL Server database rule, it is suggested that you use either the Item or ItemByID method of the collection to extract the object referencing the correct rule as illustrated earlier, then use the Remove method of the Rule object to remove the constraint.

[!참고] Creating or removing SQL Server data integrity constraints implemented as a database rule by using the Rules collection requires appropriate privilege. The SQL Server login used for SQLServer object connection must be a member of the fixed role db_ddladmin or a role with greater privilege.