Rules Bound to Columns

Bind a rule to a column using sp_bindrule with the rule name and the quoted table name and column name.

For example, to bind pub_idrule to publishers.pub_id, use:
sp_bindrule pub_idrule, "publishers.pub_id"

This rule ensures that all postal codes entered have 946 as the first 3 digits:

create rule postalcoderule946 
as @postalcode like "946[0-9][0-9]"

Bind it to the postalcode column in friends_etc like this:

sp_bindrule postalcoderule946, "friends_etc.postalcode"

Rules cannot be bound to columns and used during the same batch. sp_bindrule cannot be in the same batch as insert statements that invoke the rule.