创建2个bat文件,CREATE_ALL.bat和CREATE_ALL_File.bat文件。具体内容如下:
CREATE_ALL.bat
ECHO OFF
REM 请设定下面内容
REM SET Driver=D:
REM SET FilePath=D:/MyWork/SQL/
SET User_ID=andy
SET User_PWD=andy
SET ServerName=AndyServer
SET HostName=172.23.9.27
SET DBName=andy
SET Next=------------------------------------------
SET CommandStr=isql -U %User_ID%
SET CommandStr=%CommandStr% -P %User_PWD%
SET CommandStr=%CommandStr% -S %ServerName%
SET CommandStr=%CommandStr% -H %HostName%
SET CommandStr=%CommandStr% -d %DBName%
SET CommandStr=%CommandStr% -i %FilePath%
REM %Driver%
REM CD %FilePath%
REM 执行指定目录中的所有的sql文件
for %%i in (*.sql) do call CREATE_ALL_File.bat %%i
ECHO SQL文件执行完成,请确认上面的执行结果。
pause
----------------------------------------------------------------
CREATE_ALL_File.bat
SET FileName=%1
ECHO %1
SET CommandStrTB=%CommandStr%%FileName%
ECHO %CommandStrTB%
%CommandStrTB%
ECHO .
ECHO %Next%
使用方法:
1.将上述2个文件复制到包含sql文件的目录中;
2.双击CREATE_ALL.bat文件执行即可。