if you want to executethe SQL multiples files
first step
Place the files in that order number is the best option so it will come in that order you want to execute
1.sql
2.sql
3.sql
Now the main step place this .BAT file in the directory from which you want the .SQL files to be executed, double click the .BAT file and you are done!
we have two options to create a .bat file
1-with if you want to give user and password for that sql server connection
2-second one is with out password.
------------------------------------This one is for without Password-----------------------------------------
for %%G in (*.sql) do sqlcmd /S servername /d databaseName -E -i"%%G"
pause
------------------------------------This one is for with User and Password-----------------------------------------
for %%G in (*.sql) do sqlcmd /S servername /d databaseName -U username -P
password -i"%%G"
Note that the "-E" is not needed when user/password is provided
No comments:
Post a Comment