2

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!

1

1 Answer 1

3

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
Sign up to request clarification or add additional context in comments.

1 Comment

As of SQL Server 2005, I would recommend using sqlcmd.exe instead of osql - but other than that - good answer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.