473,395 Members | 1,652 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,395 software developers and data experts.

executenonquery vs transaction sqlclient/sql server

When using the sqlclient dotnet class and sql server.

is it faster when doing a single (not multiple) insert to:

1- just do a simple connection and command object, then execute a nonquery

2-use a transaction, connection and command object to execute a nonquery and
then commit the transaction

Thanks

Nov 19 '05 #1
9 1877
AFAIK, Adding a transaction to your T-Sql will introduce extra overhead -
if you don't need it, don't use it. The same rule applies to ADO.NET
SqlCommand object.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
http://blogs.apress.com/authors.php?author=Sahil Malik

"Chance Hopkins" <ch************@hotmail.com> wrote in message
news:OO**************@TK2MSFTNGP14.phx.gbl...
When using the sqlclient dotnet class and sql server.

is it faster when doing a single (not multiple) insert to:

1- just do a simple connection and command object, then execute a nonquery

2-use a transaction, connection and command object to execute a nonquery and then commit the transaction

Thanks

Nov 19 '05 #2
It is always faster to not use a transaction, but the answer really
depends on what your command does. If the query contains a single
UPDATE, INSERT, or DELETE statement, then the command is already
atomic and will have an implicit transaction.

If there are multiple statements inside, and you need them to behave
atomically (if one fails - everything inside the transaction fails and
changes rollback), then you'll need a transaction no matter what the
performance hit.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 6 Dec 2004 12:33:34 -0500, "Chance Hopkins"
<ch************@hotmail.com> wrote:
When using the sqlclient dotnet class and sql server.

is it faster when doing a single (not multiple) insert to:

1- just do a simple connection and command object, then execute a nonquery

2-use a transaction, connection and command object to execute a nonquery and
then commit the transaction

Thanks


Nov 19 '05 #3
DC in Da Houze MAAAN !! :)

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik

"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:32********************************@4ax.com...
It is always faster to not use a transaction, but the answer really
depends on what your command does. If the query contains a single
UPDATE, INSERT, or DELETE statement, then the command is already
atomic and will have an implicit transaction.

If there are multiple statements inside, and you need them to behave
atomically (if one fails - everything inside the transaction fails and
changes rollback), then you'll need a transaction no matter what the
performance hit.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 6 Dec 2004 12:33:34 -0500, "Chance Hopkins"
<ch************@hotmail.com> wrote:
When using the sqlclient dotnet class and sql server.

is it faster when doing a single (not multiple) insert to:

1- just do a simple connection and command object, then execute a nonquery
2-use a transaction, connection and command object to execute a nonquery andthen commit the transaction

Thanks

Nov 19 '05 #4
Woot! Woot!

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 6 Dec 2004 15:24:51 -0500, "Sahil Malik"
<co*****************@nospam.com> wrote:
DC in Da Houze MAAAN !! :)
- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik

"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:32********************************@4ax.com.. .
It is always faster to not use a transaction, but the answer really
depends on what your command does. If the query contains a single
UPDATE, INSERT, or DELETE statement, then the command is already
atomic and will have an implicit transaction.

If there are multiple statements inside, and you need them to behave
atomically (if one fails - everything inside the transaction fails and
changes rollback), then you'll need a transaction no matter what the
performance hit.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 6 Dec 2004 12:33:34 -0500, "Chance Hopkins"
<ch************@hotmail.com> wrote:
>When using the sqlclient dotnet class and sql server.
>
>is it faster when doing a single (not multiple) insert to:
>
>1- just do a simple connection and command object, then execute anonquery >
>2-use a transaction, connection and command object to execute a nonqueryand >then commit the transaction
>
>Thanks
>
>


Nov 19 '05 #5
Sahil and Scott

What is DC in Da Houze MAAAN !! :) and Woot Woot!
Code huh..Let it flow!
Patrick

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #6
When 2 geeks get together - you can't help but go crazy .. sorry for the
diversion man :)

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik
"Patrick Olurotimi Ige" <pa*********@crazyjohns.com.au> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
Sahil and Scott

What is DC in Da Houze MAAAN !! :) and Woot Woot!
Code huh..Let it flow!
Patrick

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #7
hehaha Sahil...
Hope i could be the third GEEK!
Patrick
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 19 '05 #8
thanks everybody for the clarification

Have a good one :-)
"Patrick Olurotimi Ige" <pa*********@crazyjohns.com.au> wrote in message
news:OO**************@tk2msftngp13.phx.gbl...
hehaha Sahil...
Hope i could be the third GEEK!
Patrick
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #9
Ok you're the honorary geek.

- Sahil Malik
http://dotnetjunkies.com/weblog/sahilmalik

"Patrick Olurotimi Ige" <pa*********@crazyjohns.com.au> wrote in message
news:OO**************@tk2msftngp13.phx.gbl...
hehaha Sahil...
Hope i could be the third GEEK!
Patrick
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 19 '05 #10

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

Similar topics

10
by: Mike | last post by:
I know this sounds strange but I am at a loss. I am calling a simple funtion that opens a connection to a SQL Server 2000 database and executes an Insert Statement. private void...
8
by: Don Riesbeck Jr. | last post by:
I have an C# EnterpriseService component that is part of an application I am developing that is responsible for writing data to an SQL Server. (it reads from a local DB (MSDE), then writes to a...
0
by: RJN | last post by:
Hi I'm using ServiceConfig class for handling across component transactions. My .Net application is running on windows 2003 server. database is SQLServer. The application works fine if the...
0
by: RJN | last post by:
Hi Sorry for posting this message again. I'm using ServiceConfig class for handling across component transactions. My .Net application is running on windows 2003 server. database is SQLServer....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
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...

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.