DOS command to run all SQL scripts in a path

/ Published in: DOS Batch
Save to your folder(s)

This assumes that you have sqlcmd (comes with SQL Server client tools) installed and wish to execute every file ending in .sql within the given directory against the specified server and database using Windows Authentication.

Copy this code and paste it in your HTML
  1. for %f in ("c:\path\to\dir\*.sql") do sqlcmd -S [SERVER_NAME] -d [DATABASE_NAME] -i "%f" -b

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.