I'm completely unfamiliar with windows scripting - I can roughly read it and see what's going on but when it comes to writing I'm basically at zero. Here's what I'm trying to do. I have the following script
echo on
SET LOGNAME=%7
SET LOGNAME=%LOGNAME%.log
Set CURRDATE=%TEMP%\CURRDATE.TMP
Set CURRTIME=%TEMP%\CURRTIME.TMP
DATE /T > %CURRDATE%
TIME /T > %CURRTIME%
Set PARSEARG="eol=; tokens=1,2,3,4* delims=/, "
For /F %PARSEARG% %%i in (%CURRDATE%) Do SET YYYYMMDD=%%l%%k%%j%%i
Set PARSEARG="eol=; tokens=1,2,3,4* delims=:,. "
For /F %PARSEARG% %%i in (%CURRTIME%) Do Set HHMMSS=%%i%%j%%k%%l
sqlcmd -E -S %1 -d %2 -h-1 -b -w 1000 -Q "EXEC spTest %3,%4,%5 " -o %6Test_%YYYYMMDD%%HHMMSS%.DAT
IF ERRORLEVEL 1 GOTO FAILED
ECHO %YYYYMMDD% %HHMMSS% OK>>%LOGNAME%
GOTO END
:FAILED
ECHO %YYYYMMDD% %HHMMSS% FAILED>>%LOGNAME%
:END
EXIT /B %ERRORLEVEL%
Unfortunately from time to time the YYYYMMDD part of the file is missing (no idea why this happens - its very rare - I can only think it might be the odd network glitch). What I want to do is have an if statement so that if YYYYMMDD is empty I set it to some default date. I was inserting the following line to my code - but this doesn't do anything for me.
if %YYYYMMDD% ==" " (set %YYYYMMDD% =20990101)
Any advice please?