1

关于 SQL 的快速问题我如何进行检查,例如:

Alter Table Invoices WITH NOCHECK
ADD CHECK 

现在这是我要添加检查的部分,以便column PaymentDate can be null if another column Payment Total is equal to 0and also that PaymentDate is not null if Payment Total is greater than 0.

4

1 回答 1

5

这是一种方法:

Alter Table Invoices WITH NOCHECK
ADD CHECK (   (PaymentTotal > 0 AND PaymentDate IS NOT NULL) 
           OR (PaymentTotal = 0 ) ) 
于 2013-08-11T18:24:58.513 回答