3.76现金银行报表中的期初数据不能从出
A问题解答
查询分析器中运行该脚本文件。
delete ac_accountbalance
declare @nyear int,@nmonth int,@accountid int
declare account_cursor cursor local forward_only static read_only
for select DISTINCT accountid from aa_mscash where accountid not in (select accountid from ac_accountbalance)
open account_cursor
fetch next from account_cursor into @accountid;
while @@fetch_status = 0
begin
select @nyear=min(nyear) from aa_mscash where accountid=@accountid
select @nmonth=min(nmonth) from aa_mscash where accountid=@accountid and nyear=@nyear
insert into ac_accountbalance(accountid,moneyid,balance,balinit,lcbalance,lcbalinit)
select accountid,moneyid,fbmbala,fbmbala,bmbala,bmbala from aa_mscash where accountid=@accountid and nyear=@nyear and nmonth=@nmonth
fetch next from account_cursor into @accountid
end
close account_cursor;
deallocate account_cursor;