views:

133

answers:

2

I need to use DbTransactions (on a single db) but I am not sure about how to make sure it will keep working when I deploy to the production environment.

What are the requirements for an application to be able to use SQL DbTransactions? Are they allowed by default in SQLServer (and what's the deal with MSDTC)?

+7  A: 

Yes, transactions are enabled by default--I don't think this is something you can disable. Each time you run a query, it probably runs as an autocommit, implicit transaction, unless otherwise specified.

MSDTC comes into play if you run distributed transactions. I'd avoid it if you can. That aspect can be disabled. If that's what you're using, then, you will need to make sure it's configured on the destination system.

Just using the DBTransaction object for simple, successive queries or transactions within stored procedures won't need MSDTC.

Michael Haren
Amen on avoiding MSDTC
Kevin
Not always easy when you app is distributed over multiple servers. (Have always managed it so far, but it tends to be a pain.)
Dems
+2  A: 

In addition to what Michael said,

There are explicit and implicit transactions, if you do not start a transaction explicit SQL Server will start an implicit transaction for you, this is necessary to make it ACID (Atomicity,Consistency,Isolation,Durability)

SQLMenace
can you provide an example of a case where an implicit transaction is started by SQL Server?
JohnIdol
Run any query without manually started a transaction and it will run itself, within an implicit transaction.
Michael Haren