I am executing a bunch of SQL scripts using SQLCMD
, and redirecting the output to a log file using the -o
switch. How do I turn off the output of SELECT queries? Errors, if any, should still be written to the log file, as usual.
If you want to log only errors, log by redirecting STDERR
rather than by using the -o
switch:
SQLCMD -S server -d database -E -r0 -Q "select 1" 2> error.log
update
Added that the -r0
switch must be set to redirect errors to STDERR