473,407 Members | 2,320 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,407 software developers and data experts.

3 SQL queries in 1 string...in what order will they execute?

Im running a querystring in vb.net and it seems as though SQL server decides
on the order in which to run the 3 queries in the string.. Is this possible?
I would think that SQL server starts with the 1st query, executes it, then
goes to the next.

For example:
************************************************** **********
Dim myQueryString as string = _
"INSERT INTO ArchivedClients(ClientNo,ClientName) " & _
"SELECT ClientNo,ClientName FROM Clients WHERE State='PA';" & _
"DELETE FROM Clients WHERE State='PA';" & _
"UPDATE someTable SET someField='thisstring';"

Dim SqlCommand As New SqlCommand(myQueryString, SqlConnection)
SqlCommand.ExecuteNonQuery()
************************************************** **********

Within the above there are 3 separate SQL queries.
Will SQL Server run them in 1-2-3 order, or is
it possible that it will switch the routine.

Thanks for any help.
Nov 18 '05 #1
2 1432
They will execute in order. However, why aren't you using a stored
procedure for this???

--
http://www.aspfaq.com/
(Reverse address to reply.)


"rooster575" <ro********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Im running a querystring in vb.net and it seems as though SQL server
decides
on the order in which to run the 3 queries in the string.. Is this
possible?
I would think that SQL server starts with the 1st query, executes it, then
goes to the next.

For example:
************************************************** **********
Dim myQueryString as string = _
"INSERT INTO ArchivedClients(ClientNo,ClientName) " & _
"SELECT ClientNo,ClientName FROM Clients WHERE State='PA';" & _
"DELETE FROM Clients WHERE State='PA';" & _
"UPDATE someTable SET someField='thisstring';"

Dim SqlCommand As New SqlCommand(myQueryString, SqlConnection)
SqlCommand.ExecuteNonQuery()
************************************************** **********

Within the above there are 3 separate SQL queries.
Will SQL Server run them in 1-2-3 order, or is
it possible that it will switch the routine.

Nov 18 '05 #2
Thanks very much, Aaron. I thought[hoped] that was the case.

I do use stored procedures when the particular query is highly used and of a
somewhat standard format. [2-3 dozen]
But, in my large web app of approx. 900-1200 asp.net pages ,with many unique
queries, I pick and choose which ones are best suited for a sproc. Many of
my queries are quite ad-hoc in nature, and I've found very little gain once
I work the magic necessary to run ad-hocs in sp's.
[Mostly though, its the sheer magnitude of different queries.]

Thanks again.
-R

"Aaron [SQL Server MVP]" <te*****@dnartreb.noraa> wrote in message
news:uR**************@TK2MSFTNGP10.phx.gbl...
They will execute in order. However, why aren't you using a stored
procedure for this???

--
http://www.aspfaq.com/
(Reverse address to reply.)


"rooster575" <ro********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Im running a querystring in vb.net and it seems as though SQL server
decides
on the order in which to run the 3 queries in the string.. Is this
possible?
I would think that SQL server starts with the 1st query, executes it, then goes to the next.

For example:
************************************************** **********
Dim myQueryString as string = _
"INSERT INTO ArchivedClients(ClientNo,ClientName) " & _
"SELECT ClientNo,ClientName FROM Clients WHERE State='PA';" & _
"DELETE FROM Clients WHERE State='PA';" & _
"UPDATE someTable SET someField='thisstring';"

Dim SqlCommand As New SqlCommand(myQueryString, SqlConnection)
SqlCommand.ExecuteNonQuery()
************************************************** **********

Within the above there are 3 separate SQL queries.
Will SQL Server run them in 1-2-3 order, or is
it possible that it will switch the routine.


Nov 18 '05 #3

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

Similar topics

1
by: Philippe Trottier | last post by:
Hi! We developped a program with VS2003 and Enterprise Library. then we switched to VS2005B2 to check the conversion between these two. Everything works fine now except one thing! The sql...
15
by: Academia | last post by:
I want a string of characters that will sort after all strings of Roman letters. Something that will display using a font like the one this note is written with. Is there such a thing? I...
1
by: Gerard Brunick | last post by:
Is there a way to do: s = "I like python %i%s of the time." print s % (99, "%") without having to pass in "%"? Thanks, Gerard
2
by: Coolboy55 | last post by:
I have an append query that runs in the AfterUpdate event of my DateCompletedBy textbox. DateCompletedBy is one of the fields I'm appending. For some reason, all other fields work fine, but...
0
by: python | last post by:
I understand that many portions of the string module are redundant with the native methods of strings and will removed in Python 3.0. Makes sense to me. But what will happen to the portions of...
0
by: Christian Heimes | last post by:
python@bdurham.com schrieb: See for yourself: http://svn.python.org/projects/python/branches/py3k/Lib/string.py Christian
4
by: manjuks | last post by:
Hi All, What is happening in the below piece of code Its printing Hello, why not world. Its working like call by value. Please clarify me on this. int main() { char *temp = (char...
2
by: unconquerable | last post by:
if of the following will execute faster if ( flag == 0) { } or if ( 0 == flag) {
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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.