CREATE TABLE DaTable(
CONSTRAINT MyConstraintName CHECK (ColumnA <> 'xxx' OR
(ColumnA = 'xxx' AND ColumnB IS NOT NULL)),
For constrains within the same record I prefer CHECK CONSTRAINTs over triggers.
With a CHECK CONSTRAINT, the rule is enforced on all records, present or future.
With a trigger, you have to "touch" (UPDATE) all present records or they won't get validated.
Last edited by Wim; 05-04-12 at 06:56.
With kind regards . . . . . SQL Server 2000/2005/2012
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2. Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages