I have about 100 scripts that needs to be executed on SSMS. How can i execute them as a batch instead of executing each individually.
I tried using this but it didn’t work.
@echo off
ECHO %USERNAME% started the batch process at %TIME% >output.txt
FOR %%? in ("1.01*.SQL") DO
(
sqlcmd.exe -S local -E -d collect -i %%? >>output.txt
)
pause
The following runs all scripts in a directory, output data to a .log file and errors to a .err.log file:
Note: An earlier version of this used
sqlcmdhowever there proved to be issues with sqlcmd missing out data in the output logs.