Running Sql-Server Generated Script files through an SqlCommand-Object

M

Matthias Steinbart

Hi there,

I have generated some SQL script-files using the SQL-Enterprise Manager (for
creation of tables, stored procedures, etc.).

When running those script files through the isql or osql utility, I have the
possibility to capture the output to a file, which is sort of importand to
me.

What I'd like to do is to write a small utility (Windows app in c#) which
will execute my sql-script-files on the SQL server. Again, I need to capture
the output. Can this be done using an SqlCommand-object providing the
contents of each individual script-file as the command text or do I have to
use isql. In both ways I'd like to know how it is possible to capture the
output.

The output is actually only required if there have been errors during
batch-execution.

Any help is greatly appreceated. Thanks in advance.

Matthias
 
B

bruce barker

sure, just parse for the go as a batch delimiter. also catch print and error
events.

-- bruce (sqlwork.com)
 
M

Matthias Steinbart

Hi Bruce,

thanks for the reply. Could you please provide some more detail? Why do I
have to parse for the GO? Does this mean I have to run a SqlCommand for each
section that ends with "GO"?

As for the Print and Error events. Could you please shortly provide info on
where to hook up on these events? I can't find any of those neither in the
SqlCommand nor in the Sql Connection objects.

Thanks for your help!

Matthias
 

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

Top