Quick Question about rules | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Quick Question about rules

Can you bind a rule to multiple columns? I would like to set up a general business rule which satisfies many different scenerios. I’m big fan of code reuse and was hoping the rule functionality could save me the trouble of copying the constraint code to many different objects.
CHECK constraints are the preferred, standard way to restrict the values in a column. CHECK constraints are also more concise than rules; there can only be one rule applied to a column, but multiple CHECK constraints can be applied. CHECK constraints are specified as part of the CREATE TABLE statement, while rules are created as separate objects and then bound to the column.
Satya SKJ
Moderator
http://www.SQL-Server-Performance.Com/forum
This posting is provided “AS IS” with no rights for the sake of knowledge sharing.
I use check constraints all the time and I am aware of their benefit. But it also seems that rules have some benefit as well. Therefore my question has more to do with code re use. Hence my question: Can I create 1 rule and bind it to 10 different objects instead of creating 10 constraints containing the exact same code?
No its not possible to bind a rule for multiple columns, and standard way to restrict the values in a column (multiple constraints can be defined on one or multiple columns). Hence due to restrictions of RULE usage of constraint is more ideal. Satya SKJ
Moderator
http://www.SQL-Server-Performance.Com/forum
This posting is provided “AS IS” with no rights for the sake of knowledge sharing.
]]>