Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 how to run multiple query files in batch?

Author  Topic 

ujjaval
Posting Yak Master

108 Posts

Posted - 2006-01-17 : 20:01:23
Hi,

On SQL Server 7, I am upgrading a database. For that I have about 20 different sql file to make modifications in different tables in database. Now, I want to create a batch file or something which executes all these sql files in order one by one.

How can I do this?

Thanks in advance,
Ujjaval

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2006-01-17 : 21:51:13
Check out the OSQL utility included with SQL Server. It allows you to run SQL statements from the command line.
Go to Top of Page

ujjaval
Posting Yak Master

108 Posts

Posted - 2006-01-17 : 22:07:00
Can you give some example.

Like here is 3 sql files for examples..

firstExecute.sql
secondExecute.sql
thirdExecute.sql

These files are stored in c:\temp\ folder.

Now, how should I use osql to tell that execute this in the order written above.

Thanks,
Ujjaval
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-01-17 : 23:32:42
create a batch file containing something like
osql -S servername -d dbname -i C:\temp\folder\firstExecute.sql <the rest of the osql paramters here>
osql -S servername -d dbname -i C:\temp\folder\secondExecute.sql
...

Refer to Books Online on detail osql syntax

-----------------
'KH'

Go to Top of Page
   

- Advertisement -