ExecuteNonQuery

N

Nick K.

I have a piece of code that gets a SQL Server stored procedure script from a
xsql file and creates the stored procedure using ExecuteNonQuery.

The code works fine except that it chokes if there is a "GO" or multiple sql
such as "SET QUOTED IDENTIFER OFF" or "GRANT EXECUTION ON MySP to [myuser]"

I really need this code to execute multiple scripts along with "GO". The
current program I am using was written in the .Net Framework 1.0. Are there
some enhancements to the .Net Framework 2.0 that would allow me to do this?
 
W

William \(Bill\) Vaughn

GO is used in SQL Server scripts. It's not supported by the TSQL
parser--it's simply used to break up a script into executable batches. It is
supported by OSQL, SQLCMD and the SQL Server Management Studio query tools.
To execute a script, you need to capture the string before the GO (a batch),
execute it and test the results and loop to the next batch. This was a lab
exercise in my TSQL class at MSU... It's not hard.

--
William (Bill) Vaughn
President and Founder Beta V Corporation
Redmond, WA
(425) 556-9205
Microsoft MVP, Author, Mentor
Microsoft MVP
 

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