In this Article I am explain how to run all sql files from a directory. Write below command in Notepad and save it with name ExecuteScript.bat (Batch file) and place inside the folder where all your script files are there.
for %%G in (*.sql) do sqlcmd /S SERVERNAME /d DBNAME -U USERNAME -P PASSWORD -i"%%G"
pause
if your Sql Server run as window authentication then use below command:
for %%G in (*.sql) do sqlcmd /S servername /d databasename -i"%%G"
pause
After create the bat file inside the folder in which your script files are there just click on the bat file your scripts will get executed.
for %%G in (*.sql) do sqlcmd /S SERVERNAME /d DBNAME -U USERNAME -P PASSWORD -i"%%G"
pause
if your Sql Server run as window authentication then use below command:
for %%G in (*.sql) do sqlcmd /S servername /d databasename -i"%%G"
pause
After create the bat file inside the folder in which your script files are there just click on the bat file your scripts will get executed.