CREATE TRIGGER trig_test
ON 订单表
for insert
AS
   update 客户表 
   set 金额=当前金额+(select 金额 from inserted) 
   where 客户表.客户编号=inserted.客户编号
END
GO

解决方案 »

  1.   

    --这样写,可以处理一次性插入订单时:一个客户多条订单记录,多个客户同时插入的的情况create trigger tr_insert on 订单表
    for insert
    as
    update 客户表 set 总金额=isnull(总金额,0)+isnull(b.金额)
    from 客户表 a join(
    select 客户编号,金额=sum(金额)
    from inserted
    group by 客户编号
    )b on a.客户编号=b.客户编号
      

  2.   

    CREATE TRIGGER trig_test
    ON 订单表
    for insert
    AS
       update 客户表 
       set 金额=当前金额+(select 金额 from inserted) 
       where 客户表.客户编号=inserted.客户编号
    END
    GO、、、、、、、、、、发生语法错误!!!
      

  3.   

    CREATE TRIGGER trig_tz ON [dbo].[item] 
    FOR INSERT
    AS
    update cust 
    set cust.money_total=cust.money_total
    where cust.cust_id=item.custid/////////在where这一段中,系统报错说:item与查询表中的所用的表名或者别名不匹配!
      

  4.   

    你上面的语法当然错了
    你的item是什么呀
    有不是inserted或者是deleted