PC Review


Reply
Thread Tools Rate Thread

ADO.Net / Multiple SQL Statements in One Command

 
 
Craig
Guest
Posts: n/a
 
      4th Mar 2008
I'm writing an application to assist in the deployment of some complex
database schema out of a working DDL script that has already been generated.

We're targeting SQL 2000 and 2005, and the script runs fine now inside Query
Analyzer / Management Studio. It's *long* though, and creates thousands of
objects (stored procs, tables, views) and hundreds of rows of pre-populated
data (just lots of inserts after the tables are created).

Is there a way I can run this giant script using System.Data.SqlClient? I
attempted a simple example and SqlConnection and SqlCommand choke on anything
with "GO" in it since it's not actually T-SQL.

Am I really going to have to try to intelligently divide this file up by
"GO" statements into individual SQL commands and run them individually or is
there some other way to execute batch statements?
 
Reply With Quote
 
 
 
 
Todd Beaulieu
Guest
Posts: n/a
 
      4th Mar 2008
As you've discovered, GO is not valid in ado.net. so, you'll either have to
break it up or run it through osql, or whatever it's called these days. Write
it to a file and shell out to the tool. It seems cheesy, but it's actually a
decent approach.

"Craig" wrote:

> I'm writing an application to assist in the deployment of some complex
> database schema out of a working DDL script that has already been generated.
>
> We're targeting SQL 2000 and 2005, and the script runs fine now inside Query
> Analyzer / Management Studio. It's *long* though, and creates thousands of
> objects (stored procs, tables, views) and hundreds of rows of pre-populated
> data (just lots of inserts after the tables are created).
>
> Is there a way I can run this giant script using System.Data.SqlClient? I
> attempted a simple example and SqlConnection and SqlCommand choke on anything
> with "GO" in it since it's not actually T-SQL.
>
> Am I really going to have to try to intelligently divide this file up by
> "GO" statements into individual SQL commands and run them individually or is
> there some other way to execute batch statements?

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple Update Set Statements or Multiple DML Statements in one thedudeminds@msn.com Microsoft Access Queries 4 11th Sep 2007 06:34 PM
multiple sql statements in OLE DB command Jerry Nettleton Microsoft Access Queries 2 18th Jun 2004 04:58 AM
Multiple statements with one command using System.Data.OracleClient Robert van Poelgeest Microsoft ADO .NET 0 3rd Mar 2004 11:44 AM
Multiple statements with one command using System.Data.OracleClient Robert van Poelgeest Microsoft ADO .NET 0 24th Feb 2004 07:12 PM
dataAdapter'rs command statements MeDhanush Microsoft ADO .NET 2 17th Sep 2003 05:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:33 AM.