这个用触发器可能不行吧? 试试吧:
if exists( select 1 from ljdd a join inserted b on a.cfid = b.cfid 
and a.wxz = b.wxz and a.dddate = b.dddate
)
update ljdd set num = num + inserted.num from inserted 估计不行。

解决方案 »

  1.   

    --这样就行了:create trigger t_insert on ljdd
    instead of insert
    as
    update ljdd set num=a.num+b.num
    from ljdd a join inserted b 
    on a.cfid=b.cfid and a.wxz=b.wxz and a.dddate=b.dddate
    insert into ljdd select a.* 
    from inserted left join ljdd b
    on a.cfid=b.cfid and a.wxz=b.wxz and a.dddate=b.dddate
    where a.cfid is null and a.wxz is null and a.dddate is null
    go