Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Tijesuni
Starting Member
4 Posts |
Posted - 2013-03-15 : 13:38:09
|
I have this tableMANAGEMENT.PAYMENTSPaymentIDPatientIDPaymentDatePaymentMethodCC_NumCC_NameCheck_NumAdvancePaymentFinalPaymentPaymentStatusPls how to i perform the following validation1)CC_Num and CC_Name will record the credit card number and name respectively.This details should be entered if payment is made by credit card Else they should be NULL2)Check_Num should record the check number. This detail should be entered if payments is made by check else it should be NULL |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2013-03-15 : 15:53:38
|
you could add a check constraint on the table. Something like this:alter table payments add constraint CK_PaymentMethod check ( (PaymentMethod = 'Credit Card' and CC_Num is not null and CC_Name is not null and Check_Num is null) OR (PaymentMethod = 'Check' and CC_Num is null and CC_Name is null and Check_Num is not null) ) Be One with the OptimizerTG |
|
|
Tijesuni
Starting Member
4 Posts |
Posted - 2013-03-16 : 04:20:28
|
thanks alot TG it worked...GOD BLESS YOU!!!This has been giving problems for a whileThanks so much |
|
|
|
|
|