Groups | Blog | Home
all groups > dotnet setup > september 2004 >

dotnet setup : Running SQL script through windows installer


BONTZ
9/8/2004 10:39:02 PM
Hi all,

I have a SQL script(pretty big in size) generated by Enterprise manager.
I need to run that script through VB to install database schema on my
database.
It includes creation of tables, users and stored procedures.

I have written a VB program, which reads the script from a text file and
use Command.executeNonQuery.
I have the program ready, but with problems :

1. If I incluide the SQL script as it is,
It throws exception : Incorrect syntax near 'GO'

2. If I exlude all 'GO's from the script,
It creates the tables and users successfully but throws exception :
Stored Procedures have to be on top in batch query.

3. If I move the procedures to the top, It throws exception at second
porcedure saying : Invalid varable or invalid sytax near procedure .

4. If I move all stored procedures to individual txt files, it works.

Now, as the acript is huge and application is still under development, I
want to work with a single file which i just generate from enterprise
manager.

Is it possible ???

Jim Hughes
9/12/2004 6:17:35 PM
GO is unique to Query Analyzer. (isqlw.exe, isql.exe, osql.exe)

Another option is to split your script based on \nGO\n and execute it in
more than one batch.

Maybe this article can help?

http://msdn.microsoft.com/msdnmag/issues/04/09/CustomDatabaseInstaller/default.aspx


[quoted text, click to view]

AddThis Social Bookmark Button