Why does SQLCMD not print results in command window?

Why does SQLCMD not print results in command window?

You are not seeing anything in the command window because you are telling SQLCMD.EXE to direct all output to a file due to using the -o switch. If you want results to go to a file and messages to go to the screen (and not into the file), then you cannot use the -o switch.

How to run SQLCMD with output file and screen?

@echo off :: this will execute the script into PROCESS.log sqlcmd -i Scripts\\STEP01.sql -o PROCESS.log -S MYSERVER -E -d MYDATABASE :: this present the contents of PROCESS.log to the screen echo The result of the query was: type PROCESS.log pause CHOICE /C:YN /M “Is the result accord?” IF ERRORLEVEL 2 GOTO ENDWITHERROR IF ERRORLEVEL 1 GOTO STEP2

Is there a way to print the output of SQL?

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! I also couldn’t find a better way then @Sparky proposed.

How to find the result of a SQLCMD query?

@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

Is there a way to suppress ” X rows affected ” in SQLCMD?

Is there a way to suppress “x rows affected” in SQLCMD from the command line? I’m running an MSBuild script and don’t want it clogging up my log on my build server. I’d rather not have to add “SET NOCOUNT ON” in every script, so if there’s a way to do it from the command line, that would be fantastic.

How to get rid of dashed line in SQLCMD?

I tries using parm -h-1 but that got rid of the column headers as well as the dashed line. 1) To remove the row count (” (139 rows affected)”) you should use SET NOCOUNT ON statement. See ref. 2) To remove column headers you should use -h parameter with value -1. See ref (section Formatting Options).

Why does excel not print the output of SQL Server?

You might need to remove the -e switch if sending the original SQL queries in script.sql to the top of the output file causes a problem when opening it in Excel (which I assume you are wanting to do given the .xls file extension).