- Create the script
- enable SQLCMD mode
- Run the above query
:setvar workpath "c:\scripts\":setvar FileToexecute "test3.sql"--:r $(workpath)$(FileToexecute):r $(workpath)test1.sql:r $(workpath)test2.sql
enabling the SQLCMD mode
using :r
joining :r with variables
unable to use buildin sqlcmd variables
batch file solution
ReplyDeletefor /f "usebackq tokens=*" %%a in (`dir /b/on *.sql`) do (
echo:%%~nxa
sqlcmd -U %uid% -P %pwd% -i %%~nxa
echo.
)