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
 Transact-SQL (2000)
 Executing script of scripts

Author  Topic 

Bouch
Starting Member

2 Posts

Posted - 2004-12-16 : 12:00:45
Hi folks,

I'm trying to write a script which simply executes a series of pre-existing scripts. This is so I can ensure that the load script for certain tables gets executed before others.

I've tried everything I can think of, including somethings that work on other transact-SQL based databases (like "read c:\sql\script1")

This has got to be easy, but damned if I can find how to do it.
I've rummaged through the ISQL help files, but can't find anything like "run" or "exec" that works on script files, they all seem to be for stored procedures.

Help!

Thanx!
Mike

X002548
Not Just a Number

15586 Posts

Posted - 2004-12-16 : 13:11:20
Put the code in a *.sql file

And place this in a *.bat file


"C:\Program Files\Microsoft SQL Server\80\Tools\Binn\osql" /d PathWeb2 /S PAERSCBVD0014 /U sa /P /i F:\Projects\EFindPru\HotFix_2004_11_09.sql /o F:\Projects\EFindPru\HotFix_2004_11_09.log



Brett

8-)
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-12-17 : 02:49:48
Have a batch file which does:

TYPE MyFileA.SQL >MyBigFile.SQL
TYPE MyFileB.SQL >>MyBigFile.SQL
TYPE MyFileC.SQL >>MyBigFile.SQL

and then execute MyBigFile.SQL

Re-run the batch file whenever any of the "element" files change

Kristen
Go to Top of Page

Bouch
Starting Member

2 Posts

Posted - 2004-12-20 : 14:29:36
Thanx X002548, that worked great.

Mike
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-12-20 : 16:37:37
Thanks for letting us know it worked...



Brett

8-)
Go to Top of Page
   

- Advertisement -