Help with Executing a .SQL file

R

Ryan Ternier

I'm having an issue with this.

I have 2 SQL files over 3000 lines long each. I need to run these files
when one of our sales people presses a button.

I can't save them as a Stored Procedure because SQL 2000 complains too much.

The Files work perfectly.

One is a DB Reset file, the other is a DB Init file where it initializes the
DB with all data in it.


I've tried loading these up in a stream reader, but .NET throws a bunch of
crap in the file - which I can take out - but it looses it's formating.

Is there a way to easily do this? Or will I have to recursively go through
each node in the file until I hit GO, then execute that?
 
B

Bob Barrows [MVP]

Ryan said:
I'm having an issue with this.

I have 2 SQL files over 3000 lines long each. I need to run these
files when one of our sales people presses a button.

I can't save them as a Stored Procedure because SQL 2000 complains
too much.

The Files work perfectly.

One is a DB Reset file, the other is a DB Init file where it
initializes the DB with all data in it.


I've tried loading these up in a stream reader, but .NET throws a
bunch of crap in the file - which I can take out - but it looses it's
formating.

Is there a way to easily do this? Or will I have to recursively go
through each node in the file until I hit GO, then execute that?

How about shelling to osql?

Or using xp_cmdshell?

Of course, you could break them up into multiple stored procedures ...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top