其他分享
首页 > 其他分享> > 应收单表头数据校验

应收单表头数据校验

作者:互联网

use AISXXXXXXXXXXX
go
if exists(select 1 where Convert(varchar(10),getdate(),120)=DATEADD(mm, DATEDIFF(mm,0,getdate()), 2) )
begin
update b set b.fallamount=V.fallamountE,b.ftaxamountfor=V.ftaxamountforE,b.ftaxamount=v.ftaxamountE, b.fnotaxamountfor=fnotaxamountforE,b.fnotaxamount=V.fnotaxamountE
from t_AR_receivable a inner join t_AR_receivableFIN b on a.fid=b.fid
inner join (select fid ,sum(fnotaxamountfor) as fnotaxamountforE,sum(fnotaxamount) as fnotaxamountE,sum(ftaxamountfor) as ftaxamountforE,sum(ftaxamount) as ftaxamountE ,sum(FALLAMOUNTFOR) AS FALLAMOUNTFORE,sum(fallamount) AS fallamountE from t_AR_receivableentry group by fid ) v on a.fid=v.fid
where (b.ftaxamount<>v.ftaxamountE or b.fnotaxamount<>v.fnotaxamountE or b.fnotaxamountfor<>v.fnotaxamountforE)

update a set a.fallamountFor=v.fallamountforE
from t_AR_receivable a inner join t_AR_receivableFIN b on a.fid=b.fid
inner join (select fid ,sum(fnotaxamountfor) as fnotaxamountforE,sum(fnotaxamount) as fnotaxamountE,sum(ftaxamountfor) as ftaxamountforE,sum(ftaxamount) as ftaxamountE ,sum(FALLAMOUNTFOR) AS FALLAMOUNTFORE,sum(fallamount) AS fallamountE from t_AR_receivableentry group by fid ) v on a.fid=v.fid
where (a.fallamountFor<>v.fallamountforE)
end
go

 

标签:fnotaxamount,ftaxamount,应收,sum,fnotaxamountforE,校验,表头,AR,fid
来源: https://www.cnblogs.com/allen1991/p/14079009.html