You don't specify which sql server you are using, in this example I will use firebird. If you use a different sql server, you have to use the correct sql commandline tool and syntax. firebird uses isql.exe.
Asuming I have the following text file "input.sql" containing 4 sql commands:
select * from CUSTOMER;
select * from DEPARTMENT;
select * from EMPLOYEE;
select * from SALES;
Then this batchfile will execute each command using isql.exe, and creates a seperate output file for each command:
@echo off
set sql_exe="C:\Program Files\Firebird\Firebird_2_5\bin\isql.exe"
set sql_options=-u sysdba -p masterkey
set sql_db="C:\Program Files\Firebird\Firebird_2_5\examples\empbuild\EMPLOYEE.FDB"
set count=1
for /f "delims=" %%a in (input.sql) do (
echo %%a > temp.sql
call :processtemp_sql
)
goto :eof
:processtemp_sql
%sql_exe% %sql_options% -i temp.sql -o output%count%.txt %sql_db%
set /A count=%count%+1
goto :eof
:eof
at the end output1.txt..output4.txt are created. Each file contains the output of one sql command.