views:

48

answers:

1

I've always done transactions from within stored procedures but now I need to wrap a bunch of "dynamic" statements executed from code against sp_executesql in a transaction.

Specifically I need the READ UNCOMMITED isolation level for these in some cases (I know what that does, and yes, that's what I need). This is SQL2008.

My question is this: If I use the BeginTransaction() method of my SqlConnection instance with the isolation level set to IsolationLevel.ReadUncommitted will that have the same effect as if I executed a stored proc that has the READ UNCOMMITED statement?

+2  A: 

Yes, it will.

The SqlConnection uses the SQL native client, and a call to BeginTransaction causes exactly this to be sent to the server:

SET TRANSACTION ISOLATION LEVEL <WHATEVER>; BEGIN TRANSACTION;
GSerg
Awesome, thanks.
kprobst