SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Who Uses Rules?

Someone submitted an article recently that walked through how to find the rules in your database, which columns they were bound to, and then how to remove them in order to replace them with Check Constraints. It was interesting because it had been a long time since I’d worked with rules.

Actually I never used them in any databases I designed, though I did run into them with some third party products. For those of you not familiar, a rule functions like a CHECK CONSTRAINT, and determines what is a valid value to put into a column. You use sp_bindrule to link a rule (like a default) to a column. As that page says, however, rules are deprecated and shouldn’t be used.

In fact, they ought to be replaced with check constraints, which function in much the same manner. It’s fairly easy to do, although determining where the rules are bound isn’t. Look for the article soon at SQLServerCentral.

And start replacing those rules with constraints. It will save you some work down the road as likely SQL 11 or SQL 12 won’t upgrade with them.

The Voice of the DBA

Steve Jones is the editor of SQLServerCentral.com and visits a wide variety of data related topics in his daily editorial. Steve has spent years working as a DBA and general purpose Windows administrator, primarily working with SQL Server since it was ported from Sybase in 1990. You can follow Steve on Twitter at twitter.com/way0utwest


No comments.

Leave a Comment

Please register or log in to leave a comment.