目前,江西省行政事业单位所使用的财务软件基本都是省财政厅统一的网络版用友软件,相关财务数据库由省财政厅统一管理,审计过程中不方便直接获取后台数据,审计过程中通常采集的数据是客户端导出的ASD格式数据。对于客户端导出的ASD格式数据,AO2011自带的所有采集模板均无法直接成功采集并生成财务账套,笔者曾提出过利用“财务软件数据库数据”进行采集的方法,但使用“财务软件数据库数据”采集方法,需要操作者有一定的数据库操作知识,且操作过程复杂,难以普遍适用,实用性不广。笔者经过深入学习和研究,探索出利用AO2011自带模板采集财政大平台数据的方法,现将相关研究思路及成果与各位审计同仁一同分享。
一、研究思路和操作方法
㈠研究思路
将客户端导出的ASD格式数据,按AO2011模板所需要的数据格式要求进行处理,并生成符合格式要求的数据集合,然后使用AO2011自带的模板进行采集。
㈡操作方法
经对AO2011自带的模板分析,发现模板“180安易2K数据库备份”所需要的表名、数据字段名称等内容与财政大平台导出的表名、数据字段内容基本一致,因此,就确定用该模板进行研究。
1、处理客户端导出的ASD格式数据。将扩展名改为txt,并去掉头尾非数据标题和非数据内容。为了提高工作量,用写批处理进行数据处理。处理语句如下:
rename *.asd *.txt
@echo off
setlocal enabledelayedexpansion
for %%1 in (*.txt)do (findstr /iL "[1]" "%%1">#
move "#" "%%1">nul 2>nul
)
上述批处理将当前文件夹中的所有扩展名为ASD文件全部修改为扩展名为txt文件,并仅显示文件有效的数据标题或数据内容部份,即去掉头尾非数据标题和非数据内容。
2、导入数据。将凭证表、科目表、余额表及相关辅助表用OpenRowset一一导入,以GL_Kmxx导入为例(假设GL_Kmxx.txt在D:\AOcaiwushuju\chuli,已存在导入目标数据库“用友导入准备”),相关语句如下:
select * into [用友导入准备].[dbo].[GL_Kmxx]
from OpenRowset('MSDASQL', 'Driver={Microsoft Text Driver (*.txt;
*.csv)};DefaultDir=D:\AOcaiwushuju\chuli;','select*from GL_Kmxx.txt')
其他相关表的导入参照GL_Kmxx导入。在导入过程中,由于准备导入的GL_Kmxx.txt等数据的列分割符为“[1]”,并不是OpenRowset默认的列分割符“,”,所以,在GL_Kmxx.txt所在的文件夹中还需要新建一个Schema.ini,新建的Schema.ini内容如下:
[GL_Kmxx.txt]
ColNameHeader=True
format=Delimited([1])
MaxScanRows=0
CharacterSet=ANSI
其他准备导入的数据表,参照上述格式也写在这个Schema.ini文件里。
3、处理数据。将导入SQL数据库中的数据,按“180安易2K数据库备份”模板数据格式要求进行处理。如模板所需的会计科目余额表和辅助科目余额是分开存放的,而所采集的数据中的科目余额表与辅助余额表是放在一张表中的,因此,需要进行处理。处理语句如下:
------------------生成会计科目余额表-------
--删除库中的dbo.GL_KMYE表
if exists(select * from sysobjects where name ='GL_KMYE' )
drop table [用友导入准备].dbo.GL_KMYE
--生成dbo.GL_KMYE
SELECT [kjnd],[yeblx],[kmdm],[wbdm] ,[gsdm]
,[kmncj]=sum(ncj),[kmncd]=sum(ncd)
INTO [用友导入准备].dbo.GL_KMYE
FROM [用友导入准备].[dbo].[GL_yeb]
GROUP BY[kjnd],[yeblx],[kmdm],[wbdm],[gsdm]
其他数据表及相关字段类型修改等,均需进行处理,此处就不一一详细列举。
4、数据备份。将处理好的数据库数据进行备份,以便之后导入使用。
5、模板导入。利AO2011中的“180安易2K数据库备份”模板将备份文件导入AO2011。
二、研究成果
为了便于推广应用,笔者将上述操作方法写成了批处理,相关研究成果内容全文如下:
㈠批处理架构
1、在D盘下建立D:\AOcaiwushuju文件夹, D:\AOcaiwushuju文件夹中分别建立文件夹“chuli”和“原始数据”,在D:\AOcaiwushuju\chuli 文件夹中建立“AO导入原始数据备份”。
2、在D:\AOcaiwushuju文件夹中,新建文件“SQL导入批处理.bat”。
3、在D:\AOcaiwushuju\chuli文件夹中,新建文件“Schema.ini”
4、在D:\AOcaiwushuju\chuli文件夹中,分别新建文件“sql脚本1.sql”、sql脚本2.sql”、sql脚本3.sql”和sql脚本4.sql”
㈡批处理文件等相关文件内容全文
1、在D:\AOcaiwushuju文件夹中新建文本文件“SQL导入批处理.txt”,在“SQL导入批处理.txt”中写如下内容:
@echo off
del D:\AOcaiwushuju\chuli\*.txt
copy D:\AOcaiwushuju\原始数据\*.asd D:\AOcaiwushuju\chuli\*.asd
cd D:\AOcaiwushuju\chuli
del GL_CZRZ.asd
rename *.asd *.txt
cd D:\AOcaiwushuju\chuli
@echo off
setlocal enabledelayedexpansion
for %%1 in (*.txt)do (findstr /iL "[1]" "%%1">#
move "#" "%%1">nul 2>nul
)
sqlcmd -U sa -P 123456 -i D:\AOcaiwushuju\chuli\sql脚本1.sql
sqlcmd -U sa -P 123456 -i D:\AOcaiwushuju\chuli\sql脚本2.sql
sqlcmd -U sa -P 123456 -i D:\AOcaiwushuju\chuli\sql脚本3.sql
cd D:\
del D:\用友导入准备.BAK
sqlcmd -U sa -P 123456 -i D:\AOcaiwushuju\chuli\sql脚本4.sql
cd D:\AOcaiwushuju\chuli
del D:\AOcaiwushuju\chuli\*.txt
del D:\AOcaiwushuju\chuli\*.BAK
copy D:\AOcaiwushuju\原始数据\*.* D:\AOcaiwushuju\chuli\AO导入原始数据备份\*.*
del D:\AOcaiwushuju\原始数据\*.TXT
del D:\AOcaiwushuju\原始数据\*.BAK
del D:\AOcaiwushuju\原始数据\*.ASD
pause
将“SQL导入批处理.txt”改名为“SQL导入批处理.bat”
2、在D:\AOcaiwushuju\chuli 文件夹中新建“Schema.txt”,内容为:
[GL_Kmxx.txt]
ColNameHeader=True
format=Delimited([1])
MaxScanRows=0
CharacterSet=ANSI
[GL_yeb.txt]
ColNameHeader=True
format=Delimited([1])
MaxScanRows=0
CharacterSet=ANSI
type=char(2000)
[GL_Pzml.txt]
ColNameHeader=True
format=Delimited([1])
MaxScanRows=0
CharacterSet=ANSI
[GL_Pznr.txt]
ColNameHeader=True
format=Delimited([1])
MaxScanRows=0
CharacterSet=ANSI
[GL_Fzxzl.txt]
ColNameHeader=True
format=Delimited([1])
MaxScanRows=0
CharacterSet=ANSI
[GL_Fzxlb.txt]
ColNameHeader=True
format=Delimited([1])
MaxScanRows=0
CharacterSet=ANSI
[PubBmxx.txt]
ColNameHeader=True
format=Delimited([1])
MaxScanRows=0
CharacterSet=ANSI
[PubKSZL.txt]
ColNameHeader=True
format=Delimited([1])
MaxScanRows=0
CharacterSet=ANSI
[GL_Xmzl.txt]
ColNameHeader=True
format=Delimited([1])
MaxScanRows=0
CharacterSet=ANSI
[GL_Xmkm.txt]
ColNameHeader=True
format=Delimited([1])
MaxScanRows=0
CharacterSet=ANSI
上述内容录入完后,将Schema.txt改名为Schema.ini
3、在D:\AOcaiwushuju\chuli 文件夹中新建“sql脚本1.sql”(可以通过SQL查询语句新建,再另存到D:\AOcaiwushuju\chuli 文件夹;也可以先新建文本文件,将相关内容复制到文本文件中,然后再将扩展名由“txt”改为“sql”。以下其他脚本的新建方法与此处相同)。内容为:
--******************删除数据库***********************************--
USE [master]
GO
DECLARE @dbname SYSNAME
SET @dbname = '用友导入准备' --这个是要删除的数据库库名
DECLARE @s NVARCHAR(1000)
DECLARE tb CURSOR LOCAL
FOR
SELECT s = 'kill ' + CAST(spid AS VARCHAR)
FROM MASTER..sysprocesses
WHERE dbid = DB_ID(@dbname)
OPEN tb
FETCH NEXT FROM tb INTO @s
WHILE @@fetch_status = 0
BEGIN
EXEC (@s)
FETCH NEXT FROM tb INTO @s
END
CLOSE tb
DEALLOCATE tb
IF exists(select * from sysdatabases where name ='用友导入准备' )
EXEC ('drop database [' + @dbname + ']')
--******************新建数据库[用友导入准备] ********************--
CREATE DATABASE [用友导入准备] ON PRIMARY
( NAME = N'用友导入准备', FILENAME = N'D:\Program Files (x86)\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\用友导入准备.mdf' , SIZE = 6144KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'用友导入准备_log', FILENAME = N'D:\Program Files (x86)\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\用友导入准备_log.ldf' , SIZE = 11200KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO
ALTER DATABASE [用友导入准备] SET COMPATIBILITY_LEVEL = 100
GO
IF (1 = FULLTEXTSERVICEPROPERTY('IsFullTextInstalled'))
begin
EXEC [用友导入准备].[dbo].[sp_fulltext_database] @action = 'enable'
end
GO
ALTER DATABASE [用友导入准备] SET ANSI_NULL_DEFAULT OFF
GO
ALTER DATABASE [用友导入准备] SET ANSI_NULLS OFF
GO
ALTER DATABASE [用友导入准备] SET ANSI_PADDING OFF
GO
ALTER DATABASE [用友导入准备] SET ANSI_WARNINGS OFF
GO
ALTER DATABASE [用友导入准备] SET ARITHABORT OFF
GO
ALTER DATABASE [用友导入准备] SET AUTO_CLOSE OFF
GO
ALTER DATABASE [用友导入准备] SET AUTO_CREATE_STATISTICS ON
GO
ALTER DATABASE [用友导入准备] SET AUTO_SHRINK OFF
GO
ALTER DATABASE [用友导入准备] SET AUTO_UPDATE_STATISTICS ON
GO
ALTER DATABASE [用友导入准备] SET CURSOR_CLOSE_ON_COMMIT OFF
GO
ALTER DATABASE [用友导入准备] SET CURSOR_DEFAULT GLOBAL
GO
ALTER DATABASE [用友导入准备] SET CONCAT_NULL_YIELDS_NULL OFF
GO
ALTER DATABASE [用友导入准备] SET NUMERIC_ROUNDABORT OFF
GO
ALTER DATABASE [用友导入准备] SET QUOTED_IDENTIFIER OFF
GO
ALTER DATABASE [用友导入准备] SET RECURSIVE_TRIGGERS OFF
GO
ALTER DATABASE [用友导入准备] SET DISABLE_BROKER
GO
ALTER DATABASE [用友导入准备] SET AUTO_UPDATE_STATISTICS_ASYNC OFF
GO
ALTER DATABASE [用友导入准备] SET DATE_CORRELATION_OPTIMIZATION OFF
GO
ALTER DATABASE [用友导入准备] SET TRUSTWORTHY OFF
GO
ALTER DATABASE [用友导入准备] SET ALLOW_SNAPSHOT_ISOLATION OFF
GO
ALTER DATABASE [用友导入准备] SET PARAMETERIZATION SIMPLE
GO
ALTER DATABASE [用友导入准备] SET READ_COMMITTED_SNAPSHOT OFF
GO
ALTER DATABASE [用友导入准备] SET HONOR_BROKER_PRIORITY OFF
GO
ALTER DATABASE [用友导入准备] SET READ_WRITE
GO
ALTER DATABASE [用友导入准备] SET RECOVERY SIMPLE
GO
ALTER DATABASE [用友导入准备] SET MULTI_USER
GO
ALTER DATABASE [用友导入准备] SET PAGE_VERIFY CHECKSUM
GO
ALTER DATABASE [用友导入准备] SET DB_CHAINING OFF
GO
--*****************向数据库[用友导入准备]导入相关表*******************--
USE [用友导入准备]
GO
if exists(select * from sysobjects where name ='GL_Kmxx' )
drop table [用友导入准备].dbo.GL_Kmxx
select * into [用友导入准备].[dbo].[GL_Kmxx]
from OpenRowset('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=D:\AOcaiwushuju\chuli;',' select * from GL_Kmxx.txt')
if exists(select * from sysobjects where name ='GL_yeb' )
drop table [用友导入准备].dbo.GL_yeb
select * into [用友导入准备].[dbo].[GL_yeb]
from OpenRowset('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=D:\AOcaiwushuju\chuli;',' select * from GL_yeb.txt')
if exists(select * from sysobjects where name ='GL_Pzml' )
drop table [用友导入准备].dbo.GL_Pzml
select * into [用友导入准备].[dbo].[GL_Pzml]
from OpenRowset('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=D:\AOcaiwushuju\chuli;',' select * from GL_Pzml.txt')
if exists(select * from sysobjects where name ='GL_Pznr' )
drop table [用友导入准备].dbo.GL_Pznr
select * into [用友导入准备].[dbo].[GL_Pznr]
from OpenRowset('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=D:\AOcaiwushuju\chuli;',' select * from GL_Pznr.txt')
if exists(select * from sysobjects where name ='GL_Fzxzl' )
drop table [用友导入准备].dbo.GL_Fzxzl
select * into [用友导入准备].[dbo].[GL_Fzxzl]
from OpenRowset('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=D:\AOcaiwushuju\chuli;',' select * from GL_Fzxzl.txt')
if exists(select * from sysobjects where name ='GL_Fzxlb' )
drop table [用友导入准备].dbo.GL_Fzxlb
select * into [用友导入准备].[dbo].[GL_Fzxlb]
from OpenRowset('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=D:\AOcaiwushuju\chuli;',' select * from GL_Fzxlb.txt')
if exists(select * from sysobjects where name ='GL_Xmzl' )
drop table [用友导入准备].dbo.GL_Xmzl
select * into [用友导入准备].[dbo].[GL_Xmzl]
from OpenRowset('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=D:\AOcaiwushuju\chuli;',' select * from GL_Xmzl.txt')
if exists(select * from sysobjects where name ='GL_Xmkm' )
drop table [用友导入准备].dbo.GL_Xmkm
select * into [用友导入准备].[dbo].[GL_Xmkm]
from OpenRowset('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=D:\AOcaiwushuju\chuli;',' select * from GL_Xmkm.txt')
if exists(select * from sysobjects where name ='PubBmxx' )
drop table [用友导入准备].dbo.PubBmxx
select * into [用友导入准备].[dbo].[PubBmxx]
from OpenRowset('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=D:\AOcaiwushuju\chuli;',' select * from PubBmxx.txt')
if exists(select * from sysobjects where name ='PubKSZL' )
drop table [用友导入准备].dbo.PubKSZL
select * into [用友导入准备].[dbo].[PubKSZL]
from OpenRowset('MSDASQL', 'Driver={Microsoft Text Driver (*.txt; *.csv)};DefaultDir=D:\AOcaiwushuju\chuli;',' select * from PubKSZL.txt')
--******************修改相关数据表中的字段********************--
USE [用友导入准备]
GO
alter table [用友导入准备].[dbo].[GL_Pzml] add kjnd varchar(50)
alter table [用友导入准备].[dbo].[GL_Pznr] add kjnd varchar(50)
alter table [用友导入准备].[dbo].[GL_yeb] alter column ncj decimal(38,2)
alter table [用友导入准备].[dbo].[GL_yeb] alter column ncd decimal(38,2)
alter table [用友导入准备].[dbo].[GL_Pznr] alter column je decimal(38,2)
alter table [用友导入准备].[dbo].[GL_Xmzl] add LBDM varchar(50)
alter table [用友导入准备].[dbo].[GL_Xmzl] add LBMC varchar(50)
alter table [用友导入准备].[dbo].[PubKSZL] add LBDM varchar(50)
alter table [用友导入准备].[dbo].[PubKSZL] add LBMC varchar(50)
alter table [用友导入准备].[dbo].[PubBmxx] add LBDM varchar(50)
alter table [用友导入准备].[dbo].[PubBmxx] add LBMC varchar(50)
4、在D:\AOcaiwushuju\chuli 文件夹新建“sql脚本2.sql”,内容为:
----------生成会计科目余额表-------
--删除库中的dbo.GL_KMYE--
USE [用友导入准备]
if exists(select * from sysobjects where name ='GL_KMYE' )
drop table [用友导入准备].dbo.GL_KMYE
--生成dbo.GL_KMYE
SELECT [kjnd],[yeblx],[kmdm],[wbdm],[gsdm]
,[kmncj]=sum(ncj),[kmncd]=sum(ncd)
INTO [用友导入准备].dbo.GL_KMYE
FROM [用友导入准备].[dbo].[GL_yeb]
GROUP BY[kjnd],[yeblx],[kmdm],[wbdm],[gsdm]
--------------------------------------------------------------------
UPDATE [用友导入准备].[dbo].[GL_Pzml] set kjnd=LEFT(KJQJ,4) FROM [用友导入准备].[dbo].[GL_Pzml]
UPDATE [用友导入准备].[dbo].[GL_Pznr] set kjnd=LEFT(KJQJ,4) FROM [用友导入准备].[dbo].[GL_Pznr]
--*********************修正辅助余额表*********************--
SELECT * into [用友导入准备].[dbo].[GL_FZYE]
FROM [用友导入准备AA].[dbo].[GL_yeb]
SELECT *, [wbdm]='',[gsdm]='' into [用友导入准备].[dbo].[GL_KMYE2]
FROM (SELECT A.[kjnd] ,[yeblx]=ISNULL(A.[yeblx],'b') ,[kmdm]=LEFT(B.[kmdm],4)
,[kmncj]= SUM(ISNULL(A.[kmncj],0) ) ,[kmncd]=SUM(ISNULL(A.[kmncd],0))
FROM [用友导入准备].[dbo].[GL_KMYE] A
RIGHT JOIN [用友导入准备]. [dbo].[GL_Kmxx] B ON A.kmdm=B.KMDM
WHERE B.KMMX='1' AND LEN (B.[kmdm])>=6
GROUP BY A.[kjnd],ISNULL(A.[yeblx],'b') ,LEFT(B.[kmdm],4)) C
insert into [用友导入准备].[dbo].[GL_KMYE2]
SELECT *, [wbdm]='',[gsdm]=''
FROM ( SELECT A.[kjnd], [yeblx]=ISNULL(A.[yeblx],'b') ,[kmdm]=LEFT(B.[kmdm],6)
,[kmncj]= SUM(ISNULL(A.[kmncj],0) ) ,[kmncd]=SUM(ISNULL(A.[kmncd],0))
FROM [用友导入准备].[dbo].[GL_KMYE] A
RIGHT JOIN [用友导入准备]. [dbo].[GL_Kmxx] B ON A.kmdm=B.KMDM
WHERE B.KMMX='1' AND LEN (B.[kmdm])>=8
GROUP BY A.[kjnd],ISNULL(A.[yeblx],'b') ,LEFT(B.[kmdm],6)) C
insert into [用友导入准备].[dbo].[GL_KMYE2]
SELECT *, [wbdm]='',[gsdm]=''
FROM (SELECT A.[kjnd], [yeblx]=ISNULL(A.[yeblx],'b'),[kmdm]=LEFT(B.[kmdm],8)
,[kmncj]= SUM(ISNULL(A.[kmncj],0) ) ,[kmncd]=SUM(ISNULL(A.[kmncd],0))
FROM [用友导入准备].[dbo].[GL_KMYE] A
RIGHT JOIN [用友导入准备]. [dbo].[GL_Kmxx] B ON A.kmdm=B.KMDM
WHERE B.KMMX='1' AND LEN (B.[kmdm])>=10
GROUP BY A.[kjnd],ISNULL(A.[yeblx],'b') ,LEFT(B.[kmdm],8)) C
insert into [用友导入准备].[dbo].[GL_KMYE]
select [gsdm],[kjnd],[yeblx],[kmdm],[wbdm],[kmncj],[kmncd]
from [用友导入准备].[dbo].[GL_KMYE2]
--*********************规范相关数据表中的数据*********************--
update [用友导入准备].[dbo].[GL_KMYE] set[kjnd] ='' where [kjnd] is null
update [用友导入准备].[dbo].[GL_KMYE] set[yeblx] ='' where [yeblx] is null
update [用友导入准备].[dbo].[GL_KMYE]set[kmdm] ='' where [kmdm] is null
update [用友导入准备].[dbo].[GL_KMYE]set[wbdm] ='' where [wbdm] is null
update[用友导入准备].[dbo].[GL_KMYE]set[gsdm] ='' where [gsdm] is null
update[用友导入准备].[dbo].[GL_KMYE]set[kmncj] =0 where [kmncj] is null
update[用友导入准备].[dbo].[GL_KMYE]set[kmncd] =0 where [kmncd] is null
update[用友导入准备].[dbo].[GL_Fzxlb]set[lbdm] ='' where [lbdm] is null
update[用友导入准备].[dbo].[GL_Fzxlb]set[gsdm] ='' where [gsdm] is null
update[用友导入准备].[dbo].[GL_Fzxlb]set[lbmc] ='' where [lbmc] is null
update[用友导入准备].[dbo].[GL_Fzxlb]set[lbName] ='' where [lbName] is null
update[用友导入准备].[dbo].[GL_Fzxlb]set[sflx] ='' where [sflx] is null
update[用友导入准备].[dbo].[GL_Fzxlb]set[syzt] ='' where [syzt] is null
update[用友导入准备].[dbo].[GL_Fzxlb]set[Jlr_ID] ='' where [Jlr_ID] is null
update[用友导入准备].[dbo].[GL_Fzxlb]set[Jl_RQ] ='' where [Jl_RQ] is null
update[用友导入准备].[dbo].[GL_Fzxlb]set[Xgr_ID] ='' where [Xgr_ID] is null
update[用友导入准备].[dbo].[GL_Fzxlb]set[Xg_RQ] ='' where [Xg_RQ] is null
update[用友导入准备].[dbo].[PubBmxx]set[bmdm] ='' where [bmdm] is null
update[用友导入准备].[dbo].[PubBmxx]set[gsdm] ='' where [gsdm] is null
update[用友导入准备].[dbo].[PubBmxx]set[bmmc] ='' where [bmmc] is null
update[用友导入准备].[dbo].[PubBmxx]set[bmlb] ='' where [bmlb] is null
update[用友导入准备].[dbo].[PubBmxx]set[fzrdm] ='' where [fzrdm] is null
update[用友导入准备].[dbo].[PubBmxx]set[syzt] ='' where [syzt] is null
update[用友导入准备].[dbo].[PubBmxx]set[Jlr_ID] ='' where [Jlr_ID] is null
update[用友导入准备].[dbo].[PubBmxx]set[Jl_RQ] ='' where [Jl_RQ] is null
update[用友导入准备].[dbo].[PubBmxx]set[Xgr_ID] ='' where [Xgr_ID] is null
update[用友导入准备].[dbo].[PubBmxx]set[Xg_RQ] ='' where [Xg_RQ] is null
update[用友导入准备].[dbo].[GL_Fzxzl]set[lbdm] ='' where [lbdm] is null
update[用友导入准备].[dbo].[GL_Fzxzl]set[fzdm] ='' where [fzdm] is null
update[用友导入准备].[dbo].[GL_Fzxzl]set[gsdm] ='' where [gsdm] is null
update[用友导入准备].[dbo].[GL_Fzxzl]set[fzmc] ='' where [fzmc] is null
update[用友导入准备].[dbo].[GL_Fzxzl]set[zjm] ='' where [zjm] is null
update[用友导入准备].[dbo].[GL_Fzxzl]set[syzt] ='' where [syzt] is null
update[用友导入准备].[dbo].[GL_Fzxzl]set[Jlr_ID] ='' where [Jlr_ID] is null
update[用友导入准备].[dbo].[GL_Fzxzl]set[Jl_RQ] ='' where [Jl_RQ] is null
update[用友导入准备].[dbo].[GL_Fzxzl]set[Xgr_ID] ='' where [Xgr_ID] is null
update[用友导入准备].[dbo].[GL_Fzxzl]set[Xg_RQ] ='' where [Xg_RQ] is null
update[用友导入准备].[dbo].[GL_FZYE]set[kjnd] ='' where [kjnd] is null
update[用友导入准备].[dbo].[GL_FZYE]set[kmdm] ='' where [kmdm] is null
update[用友导入准备].[dbo].[GL_FZYE]set[yeblx] ='' where [yeblx] is null
update[用友导入准备].[dbo].[GL_FZYE]set[fzdm1] ='' where [fzdm1] is null
update[用友导入准备].[dbo].[GL_FZYE]set[fzdm2] ='' where [fzdm2] is null
update[用友导入准备].[dbo].[GL_FZYE]set[wbdm] ='' where [wbdm] is null
update[用友导入准备].[dbo].[GL_FZYE]set[gsdm] ='' where [gsdm] is null
update[用友导入准备].[dbo].[GL_FZYE]set[ncj] =0 where [ncj] is null
update[用友导入准备].[dbo].[GL_FZYE]set[ncd] =0 where [ncd] is null
update[用友导入准备].[dbo].[GL_Kmxx]set[gsdm] ='' where [gsdm] is null
update[用友导入准备].[dbo].[GL_Kmxx]set[kmdm] ='' where [kmdm] is null
update[用友导入准备].[dbo].[GL_Kmxx]set[zjm] ='' where [zjm] is null
update[用友导入准备].[dbo].[GL_Kmxx]set[kmmc] ='' where [kmmc] is null
update[用友导入准备].[dbo].[GL_Kmxx]set[syzt] ='' where [syzt] is null
update[用友导入准备].[dbo].[GL_Kmxx]set[kmxz] ='' where [kmxz] is null
update[用友导入准备].[dbo].[GL_Kmxx]set[kmmxlb] ='' where [kmmxlb] is null
update[用友导入准备].[dbo].[GL_Kmxx]set[kmmx] ='' where [kmmx] is null
update[用友导入准备].[dbo].[GL_Kmxx]set[kmgs] ='' where [kmgs] is null
update[用友导入准备].[dbo].[GL_Kmxx]set[kmlb] ='' where [kmlb] is null
update[用友导入准备].[dbo].[GL_Kmxx]set[kmhdfx] ='' where [kmhdfx] is null
update[用友导入准备].[dbo].[GL_Kmxx]set[kmsyfx] ='' where [kmsyfx] is null
update[用友导入准备].[dbo].[GL_Kmxx]set[syzcfs] ='' where [syzcfs] is null
update[用友导入准备].[dbo].[GL_Kmxx]set[kmpz] ='' where [kmpz] is null
update[用友导入准备].[dbo].[GL_Kmxx]set[yefx] ='' where [yefx] is null
update[用友导入准备].[dbo].[GL_Kmxx]set[fzhs] ='' where [fzhs] is null
update[用友导入准备].[dbo].[GL_Pzml]set[gsdm] ='' where [gsdm] is null
update[用友导入准备].[dbo].[GL_Pzml]set[kjqj] ='' where [kjqj] is null
update[用友导入准备].[dbo].[GL_Pzml]set[pzly] ='' where [pzly] is null
update[用友导入准备].[dbo].[GL_Pzml]set[pzh] ='' where [pzh] is null
update[用友导入准备].[dbo].[GL_Pzml]set[pzrq] ='' where [pzrq] is null
update[用友导入准备].[dbo].[GL_Pzml]set[fjzs] ='' where [fjzs] is null
update[用友导入准备].[dbo].[GL_Pzml]set[srID] ='' where [srID] is null
update[用友导入准备].[dbo].[GL_Pzml]set[shID] ='' where [shID] is null
update[用友导入准备].[dbo].[GL_Pzml]set[jzrID] ='' where [jzrID] is null
update[用友导入准备].[dbo].[GL_Pzml]set[srrq] ='' where [srrq] is null
update[用友导入准备].[dbo].[GL_Pzml]set[shrq] ='' where [shrq] is null
update[用友导入准备].[dbo].[GL_Pzml]set[jzrq] ='' where [jzrq] is null
update[用友导入准备].[dbo].[GL_Pznr]set[gsdm] ='' where [gsdm] is null
update[用友导入准备].[dbo].[GL_Pznr]set[kjqj] ='' where [kjqj] is null
update[用友导入准备].[dbo].[GL_Pznr]set[pzly] ='' where [pzly] is null
update[用友导入准备].[dbo].[GL_Pznr]set[pzh] ='' where [pzh] is null
update[用友导入准备].[dbo].[GL_Pznr]set[flh] ='' where [flh] is null
update[用友导入准备].[dbo].[GL_Pznr]set[kmdm] ='' where [kmdm] is null
update[用友导入准备].[dbo].[GL_Pznr]set[wbdm] ='' where [wbdm] is null
update[用友导入准备].[dbo].[GL_Pznr]set[hl] ='' where [hl] is null
update[用友导入准备].[dbo].[GL_Pznr]set[jdbz] ='' where [jdbz] is null
update[用友导入准备].[dbo].[GL_Pznr]set[wbje] =0 where [wbje] is null
update[用友导入准备].[dbo].[GL_Pznr]set[je] =0 where [je] is null
update[用友导入准备].[dbo].[GL_Pznr]set[bmdm] ='' where [bmdm] is null
update[用友导入准备].[dbo].[GL_Pznr]set[wldm] ='' where [wldm] is null
update[用友导入准备].[dbo].[GL_Pznr]set[xmdm] ='' where [xmdm] is null
update[用友导入准备].[dbo].[GL_Pznr]set[fzsm8] ='' where [fzsm8] is null
update[用友导入准备].[dbo].[GL_Pznr]set[cess] ='' where [cess] is null
update[用友导入准备].[dbo].[GL_Pznr]set[fplx] ='' where [fplx] is null
update[用友导入准备].[dbo].[GL_Pznr]set[fprq] ='' where [fprq] is null
update[用友导入准备].[dbo].[GL_Pznr]set[fphfw1] ='' where [fphfw1] is null
update[用友导入准备].[dbo].[GL_Pznr]set[fphfw2] ='' where [fphfw2] is null
update[用友导入准备].[dbo].[GL_Xmzl]set[GSDM] ='' where [GSDM] is null
update[用友导入准备].[dbo].[GL_Xmzl]set[XMDM] ='' where [XMDM] is null
update[用友导入准备].[dbo].[GL_Xmzl]set[XMMC] ='' where [XMMC] is null
update[用友导入准备].[dbo].[GL_Xmzl]set[ZJM] ='' where [ZJM] is null
update[用友导入准备].[dbo].[GL_Xmzl]set[KSRQ] ='' where [KSRQ] is null
update[用友导入准备].[dbo].[GL_Xmzl]set[JSRQ] ='' where [JSRQ] is null
update[用友导入准备].[dbo].[GL_Xmzl]set[BMDM] ='' where [BMDM] is null
update[用友导入准备].[dbo].[GL_Xmzl]set[REN] ='' where [REN] is null
update[用友导入准备].[dbo].[GL_Xmzl]set[SYZT] ='' where [SYZT] is null
update[用友导入准备].[dbo].[GL_Xmzl]set[JLR_ID] ='' where [JLR_ID] is null
update[用友导入准备].[dbo].[GL_Xmzl]set[JL_RQ] ='' where [JL_RQ] is null
update[用友导入准备].[dbo].[GL_Xmzl]set[XGR_ID] ='' where [XGR_ID] is null
update[用友导入准备].[dbo].[GL_Xmzl]set[XG_RQ] ='' where [XG_RQ] is null
5、在D:\AOcaiwushuju\chuli 文件夹新建“sql脚本3.sql”,内容为:
--***如果项目辅助为空,且经济分类辅助不为空,将经济分类以项目辅助导入**--
if (select 记录数=COUNT(XMDM)
from [用友导入准备].dbo.GL_PZNR where XMDM<>'_' and XMDM<>'')=0
and (select 记录数=COUNT(XMDM)
from [用友导入准备].dbo.GL_PZNR where FZDM5<>'_' and FZDM5<>'')<>0
begin
use [用友导入准备]
if exists(select * from sysobjects where name ='GL_Xmkm' )
drop table [用友导入准备].dbo.GL_Xmkm
SELECT b.[GSDM],[KJND]=LEFT(b.kjqj,4),[XMDM]=[FZDM],[KMDM]=kmdm
into [用友导入准备].dbo.GL_Xmkm
FROM [用友导入准备].[dbo].[GL_Fzxzl] a
join [用友导入准备].dbo.GL_Pznr b on a.FZDM=b.FZDM5
end
----------------------------------------------------------------
if (select 记录数=COUNT(XMDM)
from [用友导入准备].dbo.GL_PZNR where XMDM<>'_' and XMDM<>'')=0
and (select 记录数=COUNT(XMDM)
from [用友导入准备].dbo.GL_PZNR where FZDM5<>'_' and FZDM5<>'')<>0
begin
use [用友导入准备]
if exists(select * from sysobjects where name ='GL_Xmzl' )
drop table [用友导入准备].dbo.GL_Xmzl
SELECT [GSDM],[LBDM],[XMDM]=[FZDM],[XMMC]=[FZMC],[ZJM],[F1],[F2],[SYZT]
,[BZ],[SJLY],[JLR_ID],[JL_RQ],[XGR_ID],[XG_RQ],[SFMX],[GNLB],[GNLBMC]
into[用友导入准备].[dbo].[GL_Xmzl]
FROM[用友导入准备].[dbo].[GL_Fzxzl]
end
------------------------------------------------------------------
use[用友导入准备]
if (select 记录数=COUNT(XMDM)
from [用友导入准备].dbo.GL_PZNR where XMDM<>'_' and XMDM<>'')=0
and (select 记录数=COUNT(XMDM)
from [用友导入准备].dbo.GL_PZNR where FZDM5<>'_' and FZDM5<>'')<>0
UPDATE[用友导入准备].dbo.GL_Pznr set XMDM=FZDM5
6、在D:\AOcaiwushuju\chuli 文件夹新建“sql脚本4.sql”,内容为:
USE [用友导入准备]
GO
BACKUP DATABASE 用友导入准备
TO disk = 'D:\用友导入准备.BAK'
WITH FORMAT,
NAME = 'Full Backup of MyNwind'
三、使用方法及相关说明
1、特别说明。操作时,仅需将被审计单位ASD文件全部一次性拷入“D:\AOcaiwushuju\原始数据”文件夹中,运行批处理后,会自动生成财务账套备份,同时“D:\AOcaiwushuju\原始数据”文件夹会被清空,以备处理下一个账套数据。D盘文件夹“AOcaiwushuju”中的相关批处理可以循环使用,除非以后不使用,否则运行批处理后,请不要对文件夹“AOcaiwushuju”及其内的文件进行删除、修改等操作。
2、运行批处理。根据第二项要求建好相关目录及文件后,将客户端导出的ASD格式的被审计单位财务数据全部拷贝至“D:\AOcaiwushuju\原始数据”文件夹中,然后双击运行“D:\AOcaiwushuju\ SQL导入批处理.bat”这个批处理文件,运行时间的长短取决于被审计单位财务数据的大小及计算机性能的高低,一般在5秒至1分钟时间内可以完成。
3、利用AO2011自带模板导入。运行批处理文件“SQL导入批处理.bat”后,在D盘下会生成一个数据库备份文件“用友导入准备.BAK”,打开AO2011中相应的审计项目,点击“采集转换-财务数据-财务软件备份数据-采集数据”,在弹出界面中的“转换模板”选项中,选择“180安易2K数据库备份”,在“选择数据源”选项中选择“D:\用友导入准备.BAK”。其他操作同该模板导入的正常操作,在这里就不一一介绍了。
上述操作方法,对于笔者所在的县级、乡级单位以及个别邻县县直单位等账套进行采集时,未遇到异常,但各地方、各单位在财务账套初始化过程中可能存在差异性,因此,在导入时可能需要结合实际情况对相关参数进行适当修正。(修水县审计局 叶 勇)