Export (0) Print
Expand All

Rule Class

The Rule object provides programmatic access to a SQL Server rule.

Namespace:  Microsoft.SqlServer.Management.Smo
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)

[EvaluationModeAttribute(AutomatedPolicyEvaluationMode.CheckOnSchedule)]
[PhysicalFacetAttribute(PhysicalFacetOptions.ReadOnly)]
public sealed class Rule : DefaultRuleBase, ISfcSupportsDesignMode

The Rule type exposes the following members.

  NameDescription
Public methodRule()Initializes a new instance of the Rule class.
Public methodRule(Database, String)Initializes a new instance of the Rule class on the specified database and with the specified name.
Public methodRule(Database, String, String)Initializes a new instance of the Rule class on the specified database, with the specified name and schema.
Top

  NameDescription
Public propertyCreateDateGets the time and date when the rule was created.
Public propertyDateLastModifiedGets the time and date when the rule was last modified.
Public propertyExtendedPropertiesRepresents a collection of ExtendedProperty objects. Each ExtendedProperty object represents an extended property on the Default object or the Rule object. (Inherited from DefaultRuleBase.)
Public propertyIDGets the ID value that uniquely identifies the rule.
Public propertyNameGets or sets the name of the schema. (Inherited from ScriptSchemaObjectBase.)
Public propertyParentGets or sets the Database object that is the parent of the Rule object.
Public propertyPropertiesGets a collection of Property objects that represent the object properties. (Inherited from SqlSmoObject.)
Public propertySchemaGets or sets the schema. (Inherited from ScriptSchemaObjectBase.)
Public propertyStateGets the state of the referenced object. (Inherited from SmoObjectBase.)
Public propertyTextBodyGets or sets the text that defines the default or rule. (Inherited from DefaultRuleBase.)
Public propertyTextHeaderGets or sets the header of the text body that defines the default or rule. (Inherited from DefaultRuleBase.)
Public propertyTextModeGets or sets the Boolean property value that specifies whether the Default object or Rule object header is editable as text. (Inherited from DefaultRuleBase.)
Public propertyUrnGets the Uniform Resource Name (URN) address value that uniquely identifies the object. (Inherited from SqlSmoObject.)
Public propertyUserDataGets or sets user-defined data associated with the referenced object. (Inherited from SmoObjectBase.)
Top

  NameDescription
Public methodAlterUpdates any Default object or Rule object property changes on instance of SQL Server. (Inherited from DefaultRuleBase.)
Public methodBindToColumn(String, String)Binds the default or rule to the specified column in the specified table. (Inherited from DefaultRuleBase.)
Public methodBindToColumn(String, String, String)Binds the default or rule to the specified column in the specified table with the specified schema. (Inherited from DefaultRuleBase.)
Public methodBindToDataTypeBinds the default or rule to a data type. (Inherited from DefaultRuleBase.)
Public methodChangeSchemaChanges the schema associated with the rule.
Public methodCreateCreates a default or rule on the instance of SQL Server as defined by the Default object or Rule object. (Inherited from DefaultRuleBase.)
Public methodDiscoverDiscovers a list of type Object. (Inherited from SqlSmoObject.)
Public methodDropRemoves the rule or the default. (Inherited from DefaultRuleBase.)
Public methodEnumBoundColumnsEnumerates a list of columns to which the default or rule is bound. (Inherited from DefaultRuleBase.)
Public methodEnumBoundDataTypesEnumerates a list of data types to which the default or rule is bound. (Inherited from DefaultRuleBase.)
Public methodEquals (Inherited from Object.)
Protected methodFormatSqlVariantFormats an object as SqlVariant type. (Inherited from SqlSmoObject.)
Protected methodGetContextDBGets the context database that is associated with this object. (Inherited from SqlSmoObject.)
Protected methodGetDBNameGets the database name that is associated with the object. (Inherited from SqlSmoObject.)
Public methodGetHashCode (Inherited from Object.)
Protected methodGetPropValueGets a property value of the SqlSmoObject object. (Inherited from SqlSmoObject.)
Protected methodGetPropValueOptionalGets a property value of the SqlSmoObject object. (Inherited from SqlSmoObject.)
Protected methodGetPropValueOptionalAllowNullGets a property value of the SqlSmoObject object. (Inherited from SqlSmoObject.)
Protected methodGetServerObjectGets the server of the SqlSmoObject object. (Inherited from SqlSmoObject.)
Public methodGetType (Inherited from Object.)
Public methodInitialize()Initializes the object and forces the properties be loaded. (Inherited from SqlSmoObject.)
Public methodInitialize(Boolean)Initializes the object and forces the properties be loaded. (Inherited from SqlSmoObject.)
Protected methodIsObjectInitializedVerifies whether the object has been initialized. (Inherited from SqlSmoObject.)
Protected methodIsObjectInSpaceVerifies whether the object is isolated or connected to the instance of SQL Server. (Inherited from SqlSmoObject.)
Public methodRefreshRefreshes the script name. (Inherited from ScriptNameObjectBase.)
Public methodScript()Generates a Transact-SQL script that can be used to re-create the default or rule. (Inherited from DefaultRuleBase.)
Public methodScript(ScriptingOptions)Generates a Transact-SQL script that can be used to re-create the default or rule as specified by the script options. (Inherited from DefaultRuleBase.)
Public methodScriptHeaderGenerates a Transact-SQL script that can be used to re-create the default or rule header as specified by the script options. (Inherited from DefaultRuleBase.)
Protected methodSetParentImplSets the parent of the SqlSmoObject to the newParent parameter. (Inherited from SqlSmoObject.)
Public methodToStringReturns a String that represents the referenced object. (Inherited from SqlSmoObject.)
Public methodUnbindFromColumn(String, String)Unbinds the default or rule from the specified column. (Inherited from DefaultRuleBase.)
Public methodUnbindFromColumn(String, String, String)Unbinds the default or rule from the specified column with the specified table schema. (Inherited from DefaultRuleBase.)
Public methodUnbindFromDataTypeUnbinds the default or rule from the specified data type (Inherited from DefaultRuleBase.)
Public methodValidateValidates the state of an object. (Inherited from SmoObjectBase.)
Top

  NameDescription
Public eventPropertyChangedRepresents the event that occurs when a property is changed. (Inherited from SqlSmoObject.)
Public eventPropertyMetadataChangedRepresents the event that occurs when property metadata changes. (Inherited from SqlSmoObject.)
Top

  NameDescription
Explicit interface implemetationPrivate methodIAlienObject.DiscoverDiscovers any dependencies. Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SqlSmoObject.)
Explicit interface implemetationPrivate methodIAlienObject.GetDomainRootReturns the root of the domain. (Inherited from SqlSmoObject.)
Explicit interface implemetationPrivate methodIAlienObject.GetParentGets the parent of this object. Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SqlSmoObject.)
Explicit interface implemetationPrivate methodIAlienObject.GetPropertyTypeGets the type of the specified property. (Inherited from SqlSmoObject.)
Explicit interface implemetationPrivate methodIAlienObject.GetPropertyValueGets the value of the specified property. (Inherited from SqlSmoObject.)
Explicit interface implemetationPrivate methodIAlienObject.GetUrnGets the Unified Resource Name (URN) of the object. Do not reference this member directly in your code. It supports the SQL Server infrastructure. (Inherited from SqlSmoObject.)
Explicit interface implemetationPrivate methodIAlienObject.ResolveGets the instance that contains the information about the object from the Unified Resource Name (URN) of the object. (Inherited from SqlSmoObject.)
Explicit interface implemetationPrivate methodIAlienObject.SetObjectStateSets the object state to the specified SfcObjectState value. (Inherited from SqlSmoObject.)
Explicit interface implemetationPrivate methodIAlienObject.SetPropertyValueSets the property value. (Inherited from SqlSmoObject.)
Explicit interface implemetationPrivate methodISfcPropertyProvider.GetPropertySetGets the interface reference to the set of properties of this object. (Inherited from SqlSmoObject.)
Explicit interface implemetationPrivate propertyISfcSupportsDesignMode.IsDesignModeGets a Boolean value that indicates whether the object supports design mode. Identified for informational purposes only. Not supported. Future compatibility is not guaranteed.
Top

To get Rule object properties, users can be a member of the public fixed server role.

To set Rule object properties, users must have CREATE RULE permission on the parent database or be a member of the db_owner fixed database role.

To create a rule, users must have CREATE RULE permission on the parent database or be a member of the db_owner fixed database role.

To drop a rule, users must have ALTER permission on the schema to which the rule belongs.

To bind or unbind a rule to a table, users must have ALTER permission on the table.

To bind or unbind a rule to a data type, users must have ALTER permission on the schema to which the data type belongs.

Thread Safety

Any public static (Shared in Microsoft Visual Basic) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft