如果相减后gamount字段为负值则gamount等于0,这样试试: create trigger trg_insert_update on audit for insert,update as update b set gamount = case when gamount - i.aamy > 0 then gamount - i.aamy else 0 end from goods as b inner join inserted as i on b.gid = i.gid where i.acircs = 3 GO
create trigger trg_insert_update on audit
for insert,update
as
update b set gamount = case when gamount - i.aamy > 0 then gamount - i.aamy else 0 end
from goods as b inner join inserted as i on b.gid = i.gid
where i.acircs = 3
GO