掃碼下載APP
及時接收最新考試資訊及
備考信息
核對銀行對賬單與單位銀行日記賬(以下簡稱單位日記賬)是對銀行存款審計中一項重要的步驟。通過核對銀行對賬單與單位日記賬,可以查找出未達賬項,從而為發現出租、出借帳戶、挪用公款,非法出借資金等違紀問題提供線索。以往查找未達賬項采用的是手工逐行勾挑的方法。這種方法耗時長,準確性不高。尤其是對一些存取款業務頻繁的單位,手工核對更是顯得力不從心。而利用SQL游標則可以快速查找未達賬項,從而取得事半功倍的效果。
一、采集銀行對賬單和單位日記賬數據,并進行必要的整理轉換,使其對應字段的長度、數據類型相同。如:通常銀行日記賬的支票號為銀行對賬單的憑證號的后四位,因此應對銀行對賬單的憑證號作截斷處理。Update 銀行對賬單 set 憑證號=right(憑證號,4)
二、對應整理后的銀行對賬單和單位日記賬創建四個空表用于接收未達賬項記錄:單位已付銀行未付、單位已收銀行未收、銀行已付單位未付、銀行已收單位未收。如:
create table 單位已付銀行未付 (憑證日期 varchar(14),摘要 nvarchar(50),支票號 nvarchar(10),借方金額 money,貸方金額 money)
create table 單位已收銀行未收 (憑證日期 varchar(14),摘要 nvarchar(50),支票號 nvarchar(10),借方金額 money,貸方金額 money)
create table 銀行已付單位未付 (憑證日期 varchar(14),摘要 nvarchar(50),憑證號 nvarchar(10),借方金額 money,貸方金額 money)
create table 銀行已收單位未收 (憑證日期 varchar(14),摘要 nvarchar(50),憑證號 nvarchar(10),借方金額 money,貸方金額 money)
三、創建游標,將所有金額以是否有重復金額為條件分為相同金額和不同金額記錄,再做對應比較,分步篩選未達賬項:
1、篩選單位日記賬不同金額借方有銀行對賬單貸方無的記錄
declare cur1 cursor for select 借方金額 from 單位日記賬 where 借方金額 in (select 借方金額 from 單位日記賬 group by 借方金額 having count(借方金額)=1)
open cur1
declare @借方金額 money
fetch next from cur1 into @借方金額
while @@fetch_status=0
begin
if @借方金額 in (select 貸方金額 from 銀行對賬單 group by 貸方金額 having count(貸方金額)=1)
fetch next from cur1 into @借方金額
else
begin
insert into 單位已收銀行未收 select * from 單位日記賬 where 借方金額=@借方金額
fetch next from cur1 into @借方金額
end
end
close cur1
deallocate cur1
2、篩選單位日記賬不同金額貸方有銀行對賬單借方無的記錄
declare cur1 cursor for select 貸方金額 from 單位日記賬 group by 貸方金額 having count(貸方金額)=1
open cur1
declare @貸方金額 money
fetch next from cur1 into @貸方金額
while @@fetch_status=0
begin
if @貸方金額 in (select 借方金額 from 銀行對賬單
group by 借方金額 having count(借方金額)=1)
fetch next from cur1 into @貸方金額
else
begin
insert into 單位已付銀行未付 select * from 單位日記賬 where 貸方金額=@貸方金額
fetch next from cur1 into @貸方金額
end
end
close cur1
deallocate cur1
3、篩選單位日記賬相同金額借方有銀行對賬單貸方無的記錄
declare cur1 cursor for select 借方金額,count(*) 個數 from 單位日記賬 where 借方金額0 group by 借方金額 having count(借方金額)>1
open cur1
declare @借方金額 money,@個數 int
fetch next from cur1 into @借方金額,@個數
while @@fetch_status=0
begin
if @個數 =(select count(*) from 銀行對賬單 where 貸方金額=@借方金額)
fetch next from cur1 into @借方金額,@個數
else
begin
insert into 單位已收銀行未收 select * from 單位日記賬 where 借方金額=@借方金額
fetch next from cur1 into @借方金額,@個數
end
end
close cur1
deallocate cur1
4、篩選單位日記賬相同金額貸方有銀行對賬單借方無的記錄
declare cur1 cursor for select 貸方金額,count(*) 個數 from 單位日記賬 where 貸方金額0 group by 貸方金額 having count(借方金額)>1
open cur1
declare @貸方金額 money,@個數 int
fetch next from cur1 into @貸方金額,@個數
while @@fetch_status=0
begin
if @個數 =(select count(*) from 銀行對賬單 where 借方金額=@貸方金額)
fetch next from cur1 into @貸方金額,@個數
else
begin
insert into 單位已付銀行未付 select * from 單位日記賬 where 支票號 is null and 貸方金額=@貸方金額
declare cur2 cursor for select 支票號 from 單位日記賬 where 貸方金額=@貸方金額 and 支票號 is not null
open cur2
declare @支票號 varchar(10)
fetch next from cur2 into @支票號
while @@fetch_status=0
begin
if @支票號 in (select 憑證號 from 銀行對賬單 where 借方金額=@貸方金額)
fetch next from cur2 into @支票號
else
begin
insert into 單位已付銀行未付 select * from 單位日記賬 where 支票號=@支票號
fetch next from cur2 into @支票號
end
end
close cur2
deallocate cur2
fetch next from cur1 into @貸方金額,@個數
end
end
close cur1
deallocate cur1
5、篩選銀行對賬單不同金額借方有單位日記賬貸方無的記錄
declare cur1 cursor for select 借方金額 from 銀行對賬單 group by 借方金額 having count(借方金額)=1
open cur1
declare @借方金額 money
fetch next from cur1 into @借方金額
while @@fetch_status=0
begin
if @借方金額 in (select 貸方金額 from 單位日記賬 group by 貸方金額 having count(貸方金額)=1)
fetch next from cur1 into @借方金額
else
begin
insert into 銀行已付單位未付 select * from 銀行對賬單 where 借方金額=@借方金額
fetch next from cur1 into @借方金額
end
end
close cur1
deallocate cur1
6、篩選銀行對賬單不同金額貸方有單位日記賬借方無的記錄
declare cur1 cursor for select 貸方金額 from 銀行對賬單 group by 貸方金額 having count(貸方金額)=1
open cur1
declare @貸方金額 money
fetch next from cur1 into @貸方金額
while @@fetch_status=0
begin
if @貸方金額 in (select 借方金額 from 單位日記賬
group by 借方金額 having count(借方金額)=1)
fetch next from cur1 into @貸方金額
else
begin
insert into 銀行已收單位未收 select * from 銀行對賬單 where 貸方金額=@貸方金額
fetch next from cur1 into @貸方金額
end
end
close cur1
deallocate cur1
7、篩選銀行對賬單相同金額借方有單位日記賬貸方無的記錄
declare cur1 cursor for select 借方金額,count(*) 個數 from 銀行對賬單 where 借方金額0 group by 借方金額 having count(借方金額)>1
open cur1
declare @借方金額 money,@個數 int
fetch next from cur1 into @借方金額,@個數
while @@fetch_status=0
begin
if @個數 =(select count(*) from 單位日記賬 where 貸方金額=@借方金額)
fetch next from cur1 into @借方金額,@個數
else
begin
insert into 銀行已付單位未付 select * from 銀行對賬單 where 憑證號 is null and 借方金額=@借方金額
declare cur2 cursor for select 憑證號 from 銀行對賬單 where 借方金額=@借方金額 and 憑證號 is not null
open cur2
declare @憑證號 varchar(10)
fetch next from cur2 into @憑證號
while @@fetch_status=0
begin
if @憑證號 in (select 支票號 from 單位日記賬 where 貸方金額=@借方金額)
fetch next from cur2 into @憑證號
else
begin
insert into 銀行已付單位未付 select * from 銀行對賬單 where 憑證號=@憑證號
fetch next from cur2 into @憑證號
end
end
close cur2
deallocate cur2
fetch next from cur1 into @借方金額,@個數
end
end
close cur1
deallocate cur1
8、篩選銀行對賬單相同金額貸方有單位日記賬借方無的記錄
declare cur1 cursor for select 貸方金額,count(*) 個數 from 銀行對賬單 where 貸方金額0 group by 貸方金額 having count(借方金額)>1
open cur1
declare @貸方金額 money,@個數 int
fetch next from cur1 into @貸方金額,@個數
while @@fetch_status=0
begin
if @個數 =(select count(*) from 單位日記賬 where 借方金額=@貸方金額)
fetch next from cur1 into @貸方金額,@個數
else
begin
insert into 銀行已收單位未收 select * from 銀行對賬單 where 貸方金額=@貸方金額
fetch next from cur1 into @貸方金額,@個數
end
end
close cur1
deallocate cur1
上一篇:中小企業如何正確實施ERP
下一篇:AO系統審計底稿等修改小技巧
Copyright © 2000 - www.electedteal.com All Rights Reserved. 北京正保會計科技有限公司 版權所有
京B2-20200959 京ICP備20012371號-7 出版物經營許可證 京公網安備 11010802044457號
套餐D大額券
¥
去使用 主站蜘蛛池模板: 国产精品久久久久久久久久小说 | 亚洲国产精品一区二区尤物区 | 亚洲国产精品久久久久 | 日韩电影av | 久久精品国产亚洲一区二区三区 | 亚洲综合一区在线 | 国产二区精品 | 久久久久久久久国产 | 黄色在线免费视频 | 国产一区二区三区不卡在线观看 | 欧美精品福利在线 | 日韩不卡在线 | 毛片毛| 日韩一区电影 | 不卡精品 | aⅴ色国产 欧美 | 国产视频在线播放 | 午夜精品久久久久久久 | 亚洲欧美中文日韩在线v日本 | 亚洲三区视频 | 国产日韩欧美在线 | 黄网站在线免费看 | 中文字幕日韩欧美一区二区三区 | 成人黄色网 | 国产伦精品一区二区三区免 | 欧美精品入口 | 97精品久久久午夜一区二区三区 | 韩国福利一区 | 日韩中文字幕电影 | 一级毛片视频 | 日韩免费在线观看 | 国产精品一区二区三区网站 | 久久久久久国产精品 | 中文字幕av片 | 日日夜夜天天干 | 日本 国产 欧美 | 国产高清免费 | 6080yy精品一区二区三区 | 免费大片黄在线观看视频网站 | 亚洲成人精品一区二区三区 | 国产在线日韩 |