如果你把DTS包存储在SQL Server中,批处理文件就这样写: REM Type: Batch File REM Created by: Digjim REM Import all csv files to SQL Server using DTS
REM Export DIR listing to C:\MyImport\Dirlist.txt dir c:\MyImport\*.csv /b > C:\MyImport\Dirlist.txt
REM Execute DTS package for every file name in the Dirlist.txt
for /f "tokens=1,2,3" %%i in (C:\MyImport\Dirlist.txt) do "C:\Program Files\Microsoft SQL Server\80\Tools\Binn\DTSrun.exe" –S "SQL" –N "myimportdts" -U importuser -P import –A "ServerName"="DIGJIM" -A "FileName"="c:\myimport\%%i" -A "DatabaseName"="Bank"
REM Rename all the files with "old" as suffix ren c:\myimport\*.csv *.oldcsv