delete from 資產負債表 where 會計期間 = @kjqj
insert into 資產負債表(會計期間) values(@kjqj)
update 資產負債表 set 現金及現金等價物 = b
(select sum(isnull(本期借方余額
from 科目余額表 where 會計期間 = @kjqj and
科目代碼 >=
as b where a
update 資產負債表 set 應收帳款 = b
(select sum(isnull(本期借方余額
from 科目余額表 where 會計期間 = @kjqj and
科目代碼 >=
as b where a
update 資產負債表 set 壞帳准備 = b
(select sum(isnull(本期貸方余額
from 科目余額表 where 會計期間 = @kjqj and
科目代碼 =
as b where a
update 資產負債表 set 應收帳款淨值 = 應收帳款
update 資產負債表 set 流動資產總計 = 現金及現金等價物 + 應收帳款淨值
update 資產負債表 set 固定資產原值 = b
(select sum(isnull(本期借方余額
from 科目余額表 where 會計期間 = @kjqj and 科目代碼 =
as b where a
update 資產負債表 set 累計折舊 = b
(select sum(isnull(本期貸方余額
from 科目余額表 where 會計期間 = @kjqj and 科目代碼 =
as b where a
update 資產負債表 set 固定資產總計 = 固定資產原值
update 資產負債表 set 其他資產 = b
(select sum(isnull(本期借方余額
from 科目余額表 where 會計期間 = @kjqj and
科目代碼 >=
and 科目代碼 <>
as b where a
update 資產負債表 set 資產總計 = 流動資產總計 + 固定資產總計 + 其他資產
update 資產負債表 set 應付帳款 = b
(select sum(isnull(本期貸方余額
from 科目余額表 where 會計期間 = @kjqj and
科目代碼 >=
as b where a
update 資產負債表 set 預收帳款 = b
(select sum(isnull(本期貸方余額
from 科目余額表 where 會計期間 = @kjqj and
科目代碼 =
as b where a
update 資產負債表 set 應付工資 = b
(select sum(isnull(本期貸方余額
from 科目余額表 where 會計期間 = @kjqj and 科目代碼 =
as b where a
update 資產負債表 set 其他負債 = b
(select sum(isnull(本期貸方余額
from 科目余額表 where 會計期間 = @kjqj and
科目代碼 >=
as b where a
update 資產負債表 set 負債總計 = 應付帳款 + 預收帳款 + 應付工資 + 其他負債
update 資產負債表 set 實收資本 = b
(select sum(isnull(本期貸方余額
from 科目余額表 where 會計期間 = @kjqj and 科目代碼 =
as b where a
update 資產負債表 set 資本公積 = b
(select sum(isnull(本期貸方余額
from 科目余額表 where 會計期間 = @kjqj and 科目代碼 =
as b where a
update 資產負債表 set 贏余公積 = b
(select sum(isnull(本期貸方余額
from 科目余額表 where 會計期間 = @kjqj and 科目代碼 =
as b where a
update 資產負債表 set 未分配利潤 = b
(select sum(isnull(本期貸方余額
from 科目余額表 where 會計期間 = @kjqj and
科目代碼 =
as b where a
update 資產負債表 set 所有者權益總計 = 實收資本 + 資本公積 +
贏余公積 + 未分配利潤
update 資產負債表 set 負債及所有者權益總計 = 負債總計 + 所有者權益總計
commit
GO
[
From:http://tw.wingwit.com/Article/program/Delphi/201311/24740.html