Home All Groups Group Topic Archive Search About
Author
28 Jul 2006 9:04 PM
HP
Can you create a rule on more than one column? I want to create a rule for
the following condition, fldname1 != '' OR fldname2 != ''. Is it possible? if
so how?
Your help will be greatly appreciated.
THanks!

Author
28 Jul 2006 9:25 PM
Anith Sen
You may want to use CHECK constraints for this along the lines of :

CHECK ( col_1 <> '' OR col_2 <> '' )

See SQL Server Books Online for exact syntax, examples & usage details of
check constraints.

--
Anith
Author
28 Jul 2006 9:50 PM
Erland Sommarskog
HP (H*@discussions.microsoft.com) writes:
> Can you create a rule on more than one column? I want to create a rule
> for the following condition, fldname1 != '' OR fldname2 != ''. Is it
> possible? if so how?

To add to Anith's response, note that rules defined by CREATE RULE
are deprecated my Microsoft. I disagree a bit there - I think they are
excellent for user-defined types. But there is never any reason to
bind a rule directly to a column.

Instead you should use constraints, as Anith outlined.


--
Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

AddThis Social Bookmark Button