I am trying to execute a Set of SQL scripts using a batch bile. When I try this Windows batch file it doesn't run. Please tell me know how to write the script to loop through the files?
My script:
sqlcmd -S tcp:LENOVO-GH1C00\SAM -U UserName -P PassWord -i c:\SQLCMDSCRIPTS\SELECT.SQL -o C:\SELECT.txt -p -b
IF NOT [%ERRORLEVEL%] ==[0] goto get_Error
:Success
echo Finished Succesffuly
exit /B 0
goto end
:get_error
echo step Failed
exit /B 40
:end