osql -b return ERRORLEVEL but "for do ()" cleans it!

  • I think once that you have referenced %ErrorLevel%, it is automatically set to Zero as it is very volatile.

    Try to save %ErrorLevel% first with

    Set a = %ErrorLevel%

    echo a

    if not %ERRORLEVEL% == 0 goto an_ERROR_label


    N 56°04'39.16"
    E 12°55'05.25"

  • extremely volatile  I'have tried... without success. Another test:

    for  %%x in (*.sql) do (

      osql -S %SERVER% -U %MYUSER% -P %MYPWD% -b -e -n -i %%x >> %OUTPUTLOG%

      echo result: %ErrorLevel% >> %OUTPUTLOG%

    )

    after the call osql, echo of errorlevel returns 0...

Viewing 2 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply