What is the default transaction isolation level for SQL Server with ADO.NET? I am using a default installation of SQL Server and just the normal System.Data.SqlClient classes.
The isolation level of the transactional support is default to READ UNCOMMITTED. You can change it to READ COMMITTED SNAPSHOT ISOLATION by turning ON the READ_COMMITTED_SNAPSHOT database option for a user database when connected to the master database.
An interesting thing to note in connecting to a database is the IsolationLevel, which allows you to lock your transaction in various ways. The default isolation level is ReadCommitted, which allows you to alter data during a transaction.
Transaction Isolation Levels The default isolation level is REPEATABLE READ . Other permitted values are READ COMMITTED , READ UNCOMMITTED , and SERIALIZABLE .
InnoDB offers all four transaction isolation levels described by the SQL:1992 standard: READ UNCOMMITTED , READ COMMITTED , REPEATABLE READ , and SERIALIZABLE .
READ COMMITTED is the default isolation level for the Microsoft SQL Server Database Engine.
Source:
Here is how it compares to other isolation levels:
The MSDN documentation for SqlConnection.BeginTransaction()
also states Read committed
... To reset the isolation level to the default (READ COMMITTED) ...
The accepted answer by hkf gives the correct answer for transactions started manually with SqlConnection.BeginTransaction()
. Here, the default level is ReadCommitted.
However, this is not the only way to start a new transaction in ADO.NET: Transactions can also be created automatically by using the classes from the System.Transactions
namespace, in particular, by creating a TransactionScope
.
Contrary to transactions started manually, transactions created by the System.Transactions
infrastructure (and, thus, by a TransactionScope
) are Serializable.
See below link for more information:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With