I have a table with two attributes (PriceReduction and DiscountPct).
Each record must have a value in one of the attributes but not both. When
creating a new record, how do I create the constraint when the record isn't
created yet?
WBTry:
alter table MyTable
add constraint CK1_MyTable
check (
(PriceReduction is null and DiscountPct is not null)
or (PriceReduction is not null and DiscountPct is null)
)
--
Tom
----
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Toronto, ON Canada
"wb" <none> wrote in message news:eMzyTIOYGHA.5004@.TK2MSFTNGP02.phx.gbl...
I have a table with two attributes (PriceReduction and DiscountPct).
Each record must have a value in one of the attributes but not both. When
creating a new record, how do I create the constraint when the record isn't
created yet?
WB
Thursday, March 8, 2012
Contraint on table
Labels:
attributes,
contraint,
database,
discountpct,
microsoft,
mysql,
oracle,
pricereduction,
record,
server,
sql,
table,
value
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment