Run all the sql statements in a folder

Here is a lovely little gem that will run all the .sql files in a folder.

Browse to the folder in a command prompt and use this command:

for %f in (*.sql) do sqlcmd /S /d /E /i “%f”

You can of course, order you sql by prefixing 0001, 0002, etc.

I cannot take credit for this little gem, it comes from this stack overflow article.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.