Home > Uncategorized > Running a block of SQL files sequentially

Running a block of SQL files sequentially

In Enterprise manager, you can script out the schema of a database, including stored procedures & all by clicking All-Tasks then "Generate SQL script". In this you have an option to create one big SQL file, or one file per object.
I opted for one file per object, because, I wanted to create a database project, in order to put the database schema under source control, and thus multiple developers could change the database schema at the same time.
But this time, with version tracking, and all the other associated benifits of source control.
However, when you are left with 1000 or so SQL files, how do you run them all together. – I used a batch file like this:
@echo off
echo Databse installation utility
echo ——————————————
echo Useage: InstallDB [server] [database name]
for %%1 in (*.*) do osql -S %1 -E -d %2 -i %%1 -n
(You can substitue -E with -U & -P for a non-trusted connection)
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: