ALTER TABLE a ADD CHECK (returnflag IN('0','1') and case returnflag when 0 then costamount=isnull(quantity,0)*isnull(costprice,0) when 1 then amount=isnull(quantity,0)*isnull(realprice,0) end ) 这样写提示我:第 4 行: '=' 附近有语法错误。
------解决方案--------------------
SQL code
ALTER TABLE a
ADD CHECK
(
(returnflag=0 and costamount=isnull(quantity,0)*isnull(costprice,0))
or
(returnflag=1 and amount=isnull(quantity,0)*isnull(realprice,0))
)
------解决方案--------------------