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?
Yes, it will.
The SqlConnection uses the SQL native client, and a call to
BeginTransactioncauses exactly this to be sent to the server: