473,397 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

SQL Updates

Hi,

I have sql updates that I need to apply to the new version of my
application. This is a text file with bunch of updates like new
tables, stored procedures, etc.

I can run this file on sql query analyzer to apply all the updates at
once. This has bunch of "GO"s to seperate different statements.

But here is the problem. I cannot just take this file and run it thry
my objSQLDbCmd.ExecuteNonQuery(); method. I get the error.

I wrote this utility where I take one statement (delimited by
semicolon) and run it. This utility works.

So, either my file can have 'go's or semicolon. I want to have just
one and be able to run the same file thru my utility and sql query
analyzer.

Is there any way that I can just take the same file and run it in my
..net code and have the same effect?

Thanks

Jun 23 '06 #1
4 1397
Sehboo,

Why not have your application cycle through the lines in the file,
looking for "go" (which is delimited properly), and then execute the
statements sequentially as you find them? It's easy enough to break it up
into separate commands and execute them.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Sehboo" <Ma*********@gmail.com> wrote in message
news:11*********************@g10g2000cwb.googlegro ups.com...
Hi,

I have sql updates that I need to apply to the new version of my
application. This is a text file with bunch of updates like new
tables, stored procedures, etc.

I can run this file on sql query analyzer to apply all the updates at
once. This has bunch of "GO"s to seperate different statements.

But here is the problem. I cannot just take this file and run it thry
my objSQLDbCmd.ExecuteNonQuery(); method. I get the error.

I wrote this utility where I take one statement (delimited by
semicolon) and run it. This utility works.

So, either my file can have 'go's or semicolon. I want to have just
one and be able to run the same file thru my utility and sql query
analyzer.

Is there any way that I can just take the same file and run it in my
.net code and have the same effect?

Thanks

Jun 23 '06 #2
but what if "go" is part of the statement?

Nicholas Paldino [.NET/C# MVP] wrote:
Sehboo,

Why not have your application cycle through the lines in the file,
looking for "go" (which is delimited properly), and then execute the
statements sequentially as you find them? It's easy enough to break it up
into separate commands and execute them.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Sehboo" <Ma*********@gmail.com> wrote in message
news:11*********************@g10g2000cwb.googlegro ups.com...
Hi,

I have sql updates that I need to apply to the new version of my
application. This is a text file with bunch of updates like new
tables, stored procedures, etc.

I can run this file on sql query analyzer to apply all the updates at
once. This has bunch of "GO"s to seperate different statements.

But here is the problem. I cannot just take this file and run it thry
my objSQLDbCmd.ExecuteNonQuery(); method. I get the error.

I wrote this utility where I take one statement (delimited by
semicolon) and run it. This utility works.

So, either my file can have 'go's or semicolon. I want to have just
one and be able to run the same file thru my utility and sql query
analyzer.

Is there any way that I can just take the same file and run it in my
.net code and have the same effect?

Thanks


Jun 23 '06 #3
Sehboo,

SQL is a language like anything else. It has a grammar that indicates
what is valid and what is not. You need to find out how to parse it
correctly, and then perform that action on your script.

Personally, I would just look for the word "go" on a line by itself.
That's how I usually see it in scripts.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Sehboo" <Ma*********@gmail.com> wrote in message
news:11*********************@c74g2000cwc.googlegro ups.com...
but what if "go" is part of the statement?

Nicholas Paldino [.NET/C# MVP] wrote:
Sehboo,

Why not have your application cycle through the lines in the file,
looking for "go" (which is delimited properly), and then execute the
statements sequentially as you find them? It's easy enough to break it
up
into separate commands and execute them.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Sehboo" <Ma*********@gmail.com> wrote in message
news:11*********************@g10g2000cwb.googlegro ups.com...
> Hi,
>
> I have sql updates that I need to apply to the new version of my
> application. This is a text file with bunch of updates like new
> tables, stored procedures, etc.
>
> I can run this file on sql query analyzer to apply all the updates at
> once. This has bunch of "GO"s to seperate different statements.
>
> But here is the problem. I cannot just take this file and run it thry
> my objSQLDbCmd.ExecuteNonQuery(); method. I get the error.
>
> I wrote this utility where I take one statement (delimited by
> semicolon) and run it. This utility works.
>
> So, either my file can have 'go's or semicolon. I want to have just
> one and be able to run the same file thru my utility and sql query
> analyzer.
>
> Is there any way that I can just take the same file and run it in my
> .net code and have the same effect?
>
> Thanks
>

Jun 23 '06 #4
You can either usr the Diagnostics.Process.Start to run the isql for your
text file as patarmeter or run the text file with isql in command prompt
could be easier ;-)

chanmm

"Sehboo" <Ma*********@gmail.com> wrote in message
news:11*********************@g10g2000cwb.googlegro ups.com...
Hi,

I have sql updates that I need to apply to the new version of my
application. This is a text file with bunch of updates like new
tables, stored procedures, etc.

I can run this file on sql query analyzer to apply all the updates at
once. This has bunch of "GO"s to seperate different statements.

But here is the problem. I cannot just take this file and run it thry
my objSQLDbCmd.ExecuteNonQuery(); method. I get the error.

I wrote this utility where I take one statement (delimited by
semicolon) and run it. This utility works.

So, either my file can have 'go's or semicolon. I want to have just
one and be able to run the same file thru my utility and sql query
analyzer.

Is there any way that I can just take the same file and run it in my
.net code and have the same effect?

Thanks

Jun 23 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Steve Thorpe | last post by:
Hi I have have two linked SQL Servers and I am trying to get remote writes working correctly (fast). I have configured the DB link on both machines to: Point at each others DB. I have security...
3
by: Viswanatha Thalakola | last post by:
Hello, Can someone point me to getting the total number of inserts and updates on a table over a period of time? I just want to measure the insert and update activity on the tables. Thanks....
3
by: Vijay Balki | last post by:
This might be a dumb question to ask. Can someone answer me with patience.. When I have a typed or un-typed dataset, the only way I can update is like below? Dim con As New...
1
by: Ed Willis | last post by:
Where can I go to get any updates to Visual Studio .Net 2003. The check for updates always fails when I try within VS .Net 2003? Thanks.
4
by: Jerome Cohen | last post by:
This problem is driving us mad, and I saw someone else posting a very similar problem, again no support from MS! ----------------------- Win2K/IIS 5.0, web farm load balanced by Local director....
0
by: Eric Paul | last post by:
I have been in search of a better way to handle bulk inserts and updates into SQL 2000 using c# and while I have found a few different ways to accomplish this I was wondering what is considered to...
23
abouddan
by: abouddan | last post by:
Hi all, I trying to the Automatic updates. After searching for the right updates a list of 32 high priority updates, when selecting "Download Updates and install", the process of downloading...
0
by: andrewschools | last post by:
Hi, I'm using ClickOnce for all of my installations and updates. However, when I modify any of the datasets in my application, when a user downloads the new update, all their data saved in their...
1
by: =?Utf-8?B?bmVpbG9scw==?= | last post by:
Everytime I reboot my computer I get a baloon pop up that says Automatic Updates is turned off. When I try to manualy update Windows I get the following message from Internet Explorer. Automatic...
0
by: raaman rai | last post by:
This is quite irratiting to find out that my system is enabled with automatic updates and it periodically updates my pc with the latest updates. But recently i encountered network problem once the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.