By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,058 Members | 1,209 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,058 IT Pros & Developers. It's quick & easy.

executenonquery vs transaction sqlclient/sql server

P: n/a
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
Share this Question
Share on Google+
9 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.