I do some command line batch (.bat) with sqlcmd as this way:
sqlcmd -i Scripts\STEP01.sql -o PROCESS.log -S MYSERVER -E -d MYDATABASE
and i need an output file (it's works currently) and also the output trought the screen to do something like:
@echo off
echo The result of the query was:
sqlcmd -i Scripts\STEP01.sql -o PROCESS.log -S MYSERVER -E -d MYDATABASE
pause
CHOICE /C:YN /M "Is the result accord?"
IF ERRORLEVEL 2 GOTO ENDWITHERROR
IF ERRORLEVEL 1 GOTO STEP2
Note:
- Yes, the script works suscefull, it's not an issue question.
- And yes, I've a "print "something" on my sql. The log file gets the output.
Thanks a lot!
sqlcmd
- you may need to use something like a powershell script. Is powershell an option for you?