The Rules collection contains Rule objects referencing Microsoft® SQL Server™ data integrity constraints implemented as database objects called rules.
With the Rules collection, you can:
For more information about creating SQL Server rules, see Rule Object.
To remove a SQL Server data integrity constraint implemented as a rule
Set oRule = oDatabase.Rules("Rule_RowIDs", "dbo")
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 above, then use the Remove method of the Rule object to remove the constraint.
Note 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.
Add Method | Refresh Method |
Item Method | Remove Method (Collections) |
ItemByID Method |