Hi all I am new to batch files and struggling.I am using sql server 2008
I have created a single batch file that execute other batch files + sql scripts.
I would like to use variables how can I do that?
I would like to set the path as a variable.
I could have more than one path depending on the script’s location.
:On Error exit
CALL C:\mypath\Scripts\ExecSqlScripts.bat
CALL C:\mypath\Scripts\ExecSqlScriptsTwo.bat
SQLCMD -S (Local) -i C:\mypath\Scripts\InsertUsernameTwo.sql
SQLCMD -S (Local) -i C:\mypath\Scripts\InsertUsernameThree.sql
SQLCMD -S (Local) -i C:\mypath\Scripts\InsertUsernameFour.sql
Any Suggestions?
You need the
setcommand – http://www.computerhope.com/sethlp.htmThe
set
thePath=C:\mypath\Scriptscan be called from outside the batch file too.Another solution to avoiding repetitive code to use the for command.
This does the equivalent of the
CALL %thePath%\ExecSqlScripts.bat
CALL %thePath%\ExecSqlScriptsTwo.bat
This does the equivalent of the