executenonquery vs transaction sqlclient/sql server

C

Chance Hopkins

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
 
S

Scott Allen

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.
 
P

Patrick Olurotimi Ige

Sahil and Scott

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top