关于SQL的快速问题如何进行检查,如:
Alter Table Invoices WITH NOCHECK
ADD CHECK
现在,这是我要添加支票的部分,以便column PaymentDate can be null if another column Payment Total is equal to 0
和also that PaymentDate is not null if Payment Total is greater than 0
。
答案 0 :(得分:5)
这是一种方法:
Alter Table Invoices WITH NOCHECK
ADD CHECK ( (PaymentTotal > 0 AND PaymentDate IS NOT NULL)
OR (PaymentTotal = 0 ) )