Hi,
I'm trying to create a command script(.cmd file) with if statements.I don't think the if statements work here.Because even though the first if condition fails,the control always goes to LAST STEP.
Also can you please explain how to do if<<condition>> and <<condition>>
Thanks and appreciate your help on this.
Here is the code:
ECHO ON
SET JOBNAME=TEST
for /F %%G in ('sqlcmd -E -S TAMANS-SQ12DCL\SQL1A -d SalesInterface -h-1 -W -Q "set nocount on;SELECT count(*) FROM table_test"') do (@echo %BATCH_QUERY%:%%G)
if %ERRORLEVEL% equ 0 if %BATCH_QUERY% gtr 0 (GOTO LASTSTEP)
if %ERRORLEVEL% NEQ 0 (GOTO ERROR1)
:LASTSTEP
echo **********************************************
echo * COMPLETION OK *
echo **********************************************
:NORMAL
ECHO Sucessful Completion of ICV001.
SET ControlM=0
GOTO END
:ERROR1
echo **********************************************
echo * %JOBNAME% NOT OK *
echo **********************************************
echo %JOBNAME% Abended
REM THERE WAS AN ERROR!
SET CONTROLM=1
goto END
:END
ECHO %JOBNAME% done.