Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / General / March 2008

Tip: Looking for answers? Try searching our database.

ADO.Net / Multiple SQL Statements in One Command

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Craig - 04 Mar 2008 20:56 GMT
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?
Todd Beaulieu - 04 Mar 2008 22:55 GMT
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.

> 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.
[quoted text clipped - 11 lines]
> "GO" statements into individual SQL commands and run them individually or is
> there some other way to execute batch statements?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.