mstef
mstef

Reputation: 1194

SQL Server: running every sql script in a directory

I'm running SQL Server 2008 locally. I have a pile of scripts I would like to run on my local database. I can connect to the server and run them manually but I have over a 100 scripts, and I'm sure there is a way to do this. Any help is appreciated, thanks!

Upvotes: 2

Views: 185

Answers (1)

Mehmet Osmanoglu
Mehmet Osmanoglu

Reputation: 1212

You can iterate all query files in a directory and execute them with osql utility.

@echo off
for %%f in (*.sql) do (
    echo executing %%f
    osql -E -i %%f
)

pause

Upvotes: 3

Related Questions