Run all SQL files in a directory

Posted by Niladri.Biswas under Sql Server category on | Points: 40 | Views : 845
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?

c:\>for %f in (*.sql) do sqlcmd /S <servername> /d <dbname> /E /i "%f"

Comments or Responses

Login to post response