我写了两个bat,第一个import.bat:
db2cmd -i importnew.bat
第二个importnew.bat
::连接数据库
db2 connect to bras user bras using bras
set year=%date:~0,4%
set month=%date:~5,2%
set dat=%date:~8,2%
::保存导出数据的目录名
set folderpath=D:\sqlldr\data\
::当前日期
set curdate=%year%%month%%dat%
set exportpath=%folderpath%%curdate%
::判断要导出目录下的文件是否存在
if not exist %exportpath% md %exportpath%
db2 load from "%exportpath%\fhdgckfhz.del" of del MESSAGES "D:\1.log" replace into bras.fhdgckfhz;
db2 load from "%exportpath%\fhdkfhz.del" of del MESSAGES "D:\1.log" replace into bras.fhdkfhz;
db2 load from "%exportpath%\fhdsdqfhz.del" of del MESSAGES "D:\1.log" replace into bras.fhdsdqfhz;
db2 load from "%exportpath%\fhdshqfhz.del" of del MESSAGES "D:\1.log" replace into bras.fhdshqfhz;
db2 load from "%exportpath%\fhgjfhz.del" of del MESSAGES "D:\1.log" replace into bras.fhgjfhz;
db2 load from "%exportpath%\fhnbz.del" of del MESSAGES "D:\1.log" replace into bras.fhnbz;
db2 load from "%exportpath%\fhzqfhz.del" of del MESSAGES "D:\1.log" replace into bras.fhzqfhz;
db2 load from "%exportpath%\djsstc.del" of del MESSAGES "D:\1.log" replace into bras.djsstc;
db2 load from "%exportpath%\djszxtctdxx.del" of del MESSAGES "D:\1.log" replace into bras.djszxtctdxx;
db2 load from "%exportpath%\djzflrfhls.del" of del MESSAGES "D:\1.log" replace into bras.djzflrfhls;
db2 load from "%exportpath%\fhdgckmxz.del" of del MESSAGES "D:\1.log" replace into bras.fhdgckmxz;
db2 load from "%exportpath%\fhdkmxz.del" of del MESSAGES "D:\1.log" replace into bras.fhdkmxz;
db2 load from "%exportpath%\fhdsdqmxz.del" of del MESSAGES "D:\1.log" replace into bras.fhdsdqmxz;
db2 load from "%exportpath%\fhdshqmxz.del" of del MESSAGES "D:\1.log" replace into bras.fhdshqmxz;
db2 load from "%exportpath%\fhgjmxz.del" of del MESSAGES "D:\1.log" replace into bras.fhgjmxz;
db2 load from "%exportpath%\fhnbzmxz.del" of del MESSAGES "D:\1.log" replace into bras.fhnbzmxz;
db2 load from "%exportpath%\GGBZ.del" of del MESSAGES "D:\1.log" replace into bras.GGBZ;
db2 load from "%exportpath%\GGCKLL.del" of del MESSAGES "D:\1.log" replace into bras.GGCKLL;
db2 load from "%exportpath%\GGCZY.del" of del MESSAGES "D:\1.log" replace into bras.GGCZY;
db2 load from "%exportpath%\GGCZYBZ.del" of del MESSAGES "D:\1.log" replace into bras.GGCZYBZ;
db2 load from "%exportpath%\GGDKLL.del" of del MESSAGES "D:\1.log" replace into bras.GGDKLL;
db2 load from "%exportpath%\GGGJ.del" of del MESSAGES "D:\1.log" replace into bras.GGGJ;
db2 load from "%exportpath%\GGJGM.del" of del MESSAGES "D:\1.log" replace into bras.GGJGM;
db2 load from "%exportpath%\GGJSZH.del" of del MESSAGES "D:\1.log" replace into bras.GGJSZH;
db2 load from "%exportpath%\GGJYM.del" of del MESSAGES "D:\1.log" replace into bras.GGJYM;
db2 load from "%exportpath%\GGKMZD.del" of del MESSAGES "D:\1.log" replace into bras.GGKMZD;
db2 load from "%exportpath%\GGPZZL.del" of del MESSAGES "D:\1.log" replace into bras.GGPZZL;
db2 load from "%exportpath%\GGXJXMH.del" of del MESSAGES "D:\1.log" replace into bras.GGXJXMH;
db2 load from "%exportpath%\GGKHJLBH.del" of del MESSAGES "D:\1.log" replace into bras.GGKHJLBH;
db2 load from "%exportpath%\GGXTCS.del" of del MESSAGES "D:\1.log" replace into bras.GGXTCS;
db2 load from "%exportpath%\GGYWZLZD.del" of del MESSAGES "D:\1.log" replace into bras.GGYWZLZD;