07-23-2023, 11:03 AM
I'm running an SQL request in batch-file and I need to get the errorlevel as well as the output it gives. I've tried using :
for /f "tokens=*" %%i in ('%SQLCommand%') do ( ...
and in the 'do', if the errorlevel is 1, then I can do whatever I plan to do, but I can't seem to find a way to get the errorlevel from the result of the command. I'm also not sure if the errorlevel can change while in the loop, but that I was planning on testing it as so I would get a way to know if the command change the errorlevel.
for /f "tokens=*" %%i in ('%SQLCommand%') do ( ...
and in the 'do', if the errorlevel is 1, then I can do whatever I plan to do, but I can't seem to find a way to get the errorlevel from the result of the command. I'm also not sure if the errorlevel can change while in the loop, but that I was planning on testing it as so I would get a way to know if the command change the errorlevel.