Home Forums SQL Server 2008 T-SQL (SS2K8) Create batch file to selectively run SQL files RE: Create batch file to selectively run SQL files
deepforest
SSCommitted
Points: 1780
More actions
April 24, 2014 at 10:20 am
#1708494
This should work if you run it from the folder where your files are, quick and dirty:
for %%R in (*.sql) do sqlcmd -i "%%R" -S {server_name} -U {user} -P {pwd} -d {db_name}
This won't stop on any errors, but you can add some handling.