|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册账号
×
如果发现 fa_DeptScale与fa_cards中相同卡片部门不同的记录,可以用以下语句修改。
1、检查分析
select scardnum,max(sid) as sid
into tempdb..a
from fa_DeptScale
group by scardnum
select scardnum,max(scardid) as scardid
into tempdb..b
from fa_cards
group by scardnum
select * from fa_DeptScale
where sid in ( select sid from tempdb..a )
order by sid
select *from fa_cards
where scardid in (select scardid from tempdb..b )
order by scardid
select d.* from fa_DeptScale c inner join (select * from fa_cards where scardid in (select scardid from tempdb..b ))
d on c.scardnum=d.scardnum and c.sdeptnum<>d.sdeptnum where c.sid in (select sid from tempdb..a)
2、–所差金额
select sum(dblDepr3)
from fa_DeprTransactions
where scardnum in (select d.scardnum from fa_DeptScale c
inner join (select * from fa_cards where scardid in (select scardid from tempdb..b )) d
on c.scardnum=d.scardnum and c.sdeptnum<>d.sdeptnum
where c.sid in ( select sid from tempdb..a ) )
3、–修复fa_DeptScale与fa_cards相同卡片部门不一致的记录
update c
set c.sdeptnum=d.sdeptnum
from fa_DeptScale c
inner join (select * from fa_cards where scardid in (select scardid from tempdb..b )) d
on c.scardnum=d.scardnum and c.sdeptnum<>d.sdeptnum
where c.sid in ( select sid from tempdb..a )
drop table tempdb..a
drop table tempdb..b
再附上其他相关数据表
fa_DeptScale--固定资产部门比例构成表
fa_Cards_Detail--固定资产卡片明细表
fa_DeprTransactions--固定资产折旧数据表
fa_DeprTransactions_Detail--固定资产折旧数据明细表
fa_DeprVouchers--固定资产折旧分配凭证子表
如果单纯的是这就分配表的问题,直接修改fa_DeprVouchers即可。
|
|