Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
in SQL by (20.3k points)

I have a number of .sql files which I have to run in order to apply changes made by other developers on an SQL Server 2005 database. The files are named according to the following pattern:

0001 - abc.sql

0002 - abcef.sql

0003 - abc.sql


Is there a way to run all of them in one go?

1 Answer

0 votes
by (40.7k points)

Try creating the .BAT file with the following command:

for %%G in (*.sql) do sqlcmd /S servername /d databaseName -E -i"%%G"


Note: Place the .BAT file in the directory from which you want the .SQL files to be executed, double click the .BAT file and you will be done!

Related questions

Browse Categories