Batch TSQL Script with SQLDMO 
Author Message
 Batch TSQL Script with SQLDMO

Andrew,

You need to break it down into several batches. The whole purpose of go is to separate your
script into several batches. Some commands (like CREATE VIEW etc) has to be executed inside its
own batch. By removing the GO's, you had commands execute in same batch as other where it isn't
allowed.
I suggest you read the file, line by line and append into a variable. When you encounter a GO in
beginning of the line, you just .ExecuteImmediate and then continue the loop.
--
Tibor Karaszi, SQL Server MVP
Archive at: http://www.***.com/

Quote:

> Hi,

> I have a sql script that is used to upgrade a database to the latest version
> (see attached script). It runs without errors in Query Analyser. I would
> like to use SQL-DMO ExecuteImmediate method to execute this script however
> whenever I run it it outputs a multitude of errors. I know that the 'GO'
> keyword is not TSQL compliant so I changed the 'GO' to a ';' & still get the
> same results. Is it possible to execute all of my script in one go, or do I
> need to break it into smaller scripts ?

> tia

> andrew



Sun, 24 Oct 2004 14:34:51 GMT
 Batch TSQL Script with SQLDMO

Tibor,

Ta, It works great



Quote:
> Andrew,

> You need to break it down into several batches. The whole purpose of go is
to separate your
> script into several batches. Some commands (like CREATE VIEW etc) has to

be executed inside its
Quote:
> own batch. By removing the GO's, you had commands execute in same batch as

other where it isn't
Quote:
> allowed.
> I suggest you read the file, line by line and append into a variable. When

you encounter a GO in
Quote:
> beginning of the line, you just .ExecuteImmediate and then continue the
loop.
> --
> Tibor Karaszi, SQL Server MVP
> Archive at:

http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sql...
Quote:




Quote:
> > Hi,

> > I have a sql script that is used to upgrade a database to the latest
version
> > (see attached script). It runs without errors in Query Analyser. I would
> > like to use SQL-DMO ExecuteImmediate method to execute this script
however
> > whenever I run it it outputs a multitude of errors. I know that the 'GO'
> > keyword is not TSQL compliant so I changed the 'GO' to a ';' & still get
the
> > same results. Is it possible to execute all of my script in one go, or
do I
> > need to break it into smaller scripts ?

> > tia

> > andrew



Sun, 24 Oct 2004 14:45:41 GMT
 
 [ 2 post ] 

 Relevant Pages 

1. SQLDMO execute a batch SQL Script

2. Multiple Batch Scripts and SQLDMO (VB6)

3. How can I script db from tsql script?

4. Bug with SQLDMO or TSQL backup?

5. Batch Scripts How to pass parameters back to calling script

6. Transact SQL Batch command using SQLDMO

7. Transact SQL Batch command using SQLDMO

8. Running script to create tables in a database via VB (SQLDMO)

9. Using SQLDMO to script UDF's

10. Get a table script with 7.0 compatible feature using sqldmo object

11. sqldmo scripting.

12. SQLDMO script generating


 
Powered by phpBB® Forum Software