sp_bindrule

Binds a rule to a column or user-defined datatype.

Syntax

sp_bindrule rulename, objname [, futureonly]

Parameters

Examples

Usage

There are additional considerations when using sp_bindrule:
  • Create a rule using the create rule statement. Then execute sp_bindrule to bind it to a column or user-defined datatype in the current database.

  • Rules are enforced when an insert is attempted, not when sp_bindrule is executed. You can bind a character rule to a column with an exact or approximate numeric datatype, even though such an insert is illegal.

  • You cannot use sp_bindrule to bind a check constraint for a column in a create table statement.

  • You cannot bind a rule to an SAP ASE server-supplied datatype or to a text or an image column.

  • You cannot bind a rule to a system table.

  • You cannot bind a rule to a computed column.

  • If you are binding to a column, the objname argument must be of the form “table.column”. Any other format is assumed to be the name of a user-defined datatype.

  • Statements that use a rule cannot be in the same batch as their sp_bindrule statement.

  • You can bind a rule to a column or user-defined datatype without unbinding an existing rule. Rules bound to columns always take precedence over rules bound to datatypes. Binding a rule to a column replaces a rule bound to the datatype of that column; however, binding a rule to a datatype does not replace a rule bound to a column of that user-defined datatype.

  • Existing columns of the user-defined datatype inherit the new rule unless their rule was previously changed, or the value of the optional third parameter is futureonly. New columns of the user-defined datatype always inherit the rule.

See also create rule, drop rule in Reference Manual: Commands.

Permissions

You must be the table owner or user datatype owner to execute sp_bindmsg. Permission checks do not differ based on the granular permissions settings.

Auditing

Values in event and extrainfo columns from the sysaudits table are:

InformationValues
Event

8

Audit option

bind

Command or access audited

sp_bindrule

Information in extrainfo
  • Roles – Current active roles

  • Keywords or options – NULL

  • Previous value – NULL

  • Current value – NULL

  • Other information – Name of the rule

  • Proxy information – Original login name, if set proxy in effect

Related reference
sp_unbindrule