Rules bound to columns

You bind a rule to a column by using sp_bindrule with the rule name and the quoted table name and column name. This is how pub_idrule was bound to publishers.pub_id:

sp_bindrule pub_idrule, "publishers.pub_id"

Here is a rule to ensure that all the postal codes entered will 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.