create trigger trigger_ckgl_sckc on table_ckgl for insert as begin update table_sckc set xykc=xykc+yhsl from table_sckc a inner join inserted b on a.xsdw=b.yhdw and a.sph=b.sphupdate table_spmx set kcl=kcl-yhsl from table_spmx a inner join inserted b on spbh=sph end --上面应该是一个完整的触发器吧 goinsert table_ckgl(sph,yhsl) select sph,yhsl from inserted where sph not in(select sph from table_ckgl)insert table_ckgl(sph,yhsl) select sph,yhsl from inserted where sph not in(select sph from table_ckgl)
for insert
as
begin
update table_sckc
set xykc=xykc+yhsl from table_sckc a inner join inserted b on a.xsdw=b.yhdw and a.sph=b.sphupdate table_spmx
set kcl=kcl-yhsl from table_spmx a inner join inserted b on spbh=sph
end --上面应该是一个完整的触发器吧
goinsert table_ckgl(sph,yhsl)
select sph,yhsl from inserted where sph not in(select sph from table_ckgl)insert table_ckgl(sph,yhsl)
select sph,yhsl from inserted where sph not in(select sph from table_ckgl)
xykc=isnull(xykc,0)+isnull(yhsl,0)上面的改成这样试试