Error Handling with Batch File & Sqlcmd

前端 未结 4 1821
傲寒
傲寒 2021-02-07 07:19

I have a batch file that runs some SELECT queries using sqlcmd, puts the results into text files, and uploads those files onto an FTP server. That\'s all working just the way it

4条回答
  •  青春惊慌失措
    2021-02-07 07:21

    You can check errorlevel returned from SQLCMD to see if it failed.

        sqlcmd -b 
        IF ERRORLEVEL 1 goto err_handler
        goto done
        :err_handler
        REM handle the error here
    
        :done 
        REM script completion code here
    

提交回复
热议问题