SQL Flow Field Guide

:Error

Check your sqlcmd client variant and platform

Route sqlcmd messages sent to the error stream.

Syntax at a glance

:Error filename | STDERR | STDOUT

Work example

Separate errors from a data export

In a lab directory, send error output to a fresh log file. Run a statement that refers to a missing lab table, then restore STDERR.

Check your work The error appears in the chosen log. An existing destination file is truncated when sqlcmd opens it.

Open Microsoft Learn for full syntax, permissions, and details for your version.