I have written the batch file to print out max(ID) from sql server. I see for loop, looping through twice, once printing the correct iD number and in next iteration prints a bracket '('. I have no clue why it is iterating twice.
@echo on
set maxid=0
echo %maxid%
timeout /t 10
for /F "usebackq tokens=1" %%i in (`sqlcmd -E -S "DBNAME\instance01" -h-1 -Q "select max(ID) from table1"`) do set maxid=%%i
echo testingcount
echo %maxid%
timeout /t 10
if %maxid% NEQ 0 (
echo count not zero
echo %maxid%
timeout /t 10
goto end
) else if %maxid% EQU 0(
echo count is zero
timeout /t 10
}
:end
echo END
Thanks