How can you get SQLCMD, when executing a SQL script file, to just output any errors or warnings it encounters?
I essentially dont want information based messages to be output.
By default, SQLCMD sends all non-error messages and error messages to stdout. Hence, attempting to redirect output won't help.
The first thing you need to do in order to get only one or the other type of messages (error or non-error) is to tell SQLCMD to separate them by sending the error messages (severity level 11 or higher) to stderr. You do this by using the
The next part is to filter out the regular messages going to stdout. This can be done by redirecting the stdout messages to somewhere via
The following will execute the
But the following displays an error message as those are not being redirected to
Found this on SQLServerCentral
The following will work:
The output from the query will be put into the log and nothing is printed on the screen.
More details at the MSDN article on sqlcmd.