I have a batch file that should execute a sql server query and check if count = 0 or more. if 0 exit if not I run another .exe program. When I run this, the if statement "if ct EQU 0" is not working correctly. In my table count is zero.
@ECHO OFF
SET Header=-----------------------------------------------------
set ct=-1
sqlcmd -S OURDATA\DEVINSTANCE -E -q "SELECT ct=count(*) FROM [dbo].[Table] where Name like '%AMY%' and status=1"
if ct EQU 0 (
echo no count)
goto end
)
if ct GRT 0 (
start "" "C:\test.exe"
if %ERRORLEVEL% NEQ 0 (
echo %header%
Echo There has been an error.
pause
goto end)
)
:end
echo %header%
echo END
Thanks R