title: Trapping errors using cmd.exe in SQL Server job
body: <p>I have a job that runs a batch file as step1.  I edited the batch file ( mybatch.bat ) as follows:</p>
  <pre><code>     call sub: &gt;&gt;mylog.txt 
       exit /b %ERRORLEVEL%
      command1
      command2 
  </code></pre>
  <p>As you can see I forgot to add the sub. The job step is
  <code>cmd.exe mybatch.bat || echo %ERRORLEVEL% </code>.
  The job runs as successful and the history is as follows:
  <code>call :sub  1&gt;&gt;D:\Server_Directory\Logging\Cmd_Shell\SQL_APD_download.log   The system cannot find the batch label specified - sub    C:\Windows\system32&gt;exit /b 1    0.  Process Exit Code 0.  The step succeeded.</code>
  How do I get SQL to fail the job, and not report Exit Code 0  ?</p>