一個更新的觸發,大家幫我。
vfork 2006-03-18 10:27:47 table A,table B
B的flag初始為0,
當flag更新為1時,A.Amount=A.Amount+B.Amount
當flag更新為0時,A.Amount=A.Amount-B.Amount
我寫的錯誤的觸發如下:
CREATE TRIGGER In_update_store ON [dbo].B
FOR UPDATE
AS
if update(flag)
begin
update A set A.amount=A.amount-A.Bmount from inserted B where A.id=B.Mtid and B.flag=0
update A set A.amount=A.amount+B.Amount from inserted B where A.id=B.Mtid and B.flag=1
end