title: SQLCMD utility from BAT file - how to return ERRORLEVEL in case of syntax error
body: <p>How can I get %ERRORLEVEL% from SQLCMD utility when some of .sql files contains syntax error? These files create stored procedures. They don't invoke "raiseerror", but they can conatin syntax error and I need to terminate the process.
  But it always returns %ERRORLEVEL% as 0.
  I tried use -b, -V and -m (and their combinations), but nothing worked for me as expected.</p>
  
  <p>Here's the code fragment of my BAT file.</p>
  
  <pre><code>REM process all sql files in "SQL\scripts" folder and subfolders
  FOR /R "SQL\scripts" %%G IN (*.sql) DO (
      sqlcmd -d %1 -S %2 -U %3 -P %4 -i "%%G" -b -V 1
  
      echo %ERRORLEVEL%
      IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
  )
  </code></pre>