Output and exit codes: Exit codes

The 1 / 2 distinction is the one that matters most.

Last updated 2026-10-21

Code Meaning
0 Ran, everything succeeded
1 Ran, at least one target failed
2 Refused before touching anything — pre-flight, or an unconfirmed production target
3 Usage error
130 Canceled

The 1 / 2 distinction is the one that matters most. 2 means the estate was not touched: no connection was opened, nothing was read, nothing was changed. 1 means work happened and some of it failed. A pipeline that collapses every non-zero code into "it broke" throws away the only piece of information that tells it whether to page somebody about its servers.

Exit codes: 1 when the scan observed drift under --fail-on-drift, 3 for a usage error such as an unknown target group.
Exit codes: 1 when the scan observed drift under --fail-on-drift, 3 for a usage error such as an unknown target group.
sqlmc list coverage --list "All Prod" --fail-on-drift
case $? in
  0) echo "no drift observed" ;;
  1) echo "drift, or a database could not be read — investigate" ;;
  2) echo "refused; nothing was touched — probably needs --yes" ;;
  3) echo "bad invocation" ;;
  130) echo "cancelled" ;;
esac