We have some lists of data being fetched in our application via a SqlCommand performing a SELECT
query on a SQL Server database. We do not explicitly setup a transaction on the SqlCommand, instead just passing it a SqlConnection and running it. Is it the case that when no transaction is specified that SQL Server will initiate and use a default transaction with the default IsolationLevel of ReadCommitted
?
相关问题
- sql execution latency when assign to a variable
- What is the best way to cache a table from a (SQL)
- php PDO::FETCH_ASSOC doesnt detect select after ba
- Bulk update SQL Server C#
- SQL to Parse a Key-Value String
相关文章
- Entity Framework 4.3.1 failing to create (/open) a
- Code for inserting data into SQL Server database u
- Delete Every Alternate Row in SQL
- Linux based PHP install connecting to MsSQL Server
- SQL Azure Reset autoincrement
- How do we alias a Sql Server instance name used in
- Is recursion good in SQL Server?
- How can I convert a OLE Automation Date value to a
SQL Server can work happily without an explicit transaction. But yes, I believe it is essentially read-committed (unless, of course, you add extra hints to your query objects,such as
UPDLOCK
/NOLOCK
). You can investigate this with:which shows (among others):
SQL creates a transaction implicitly for your statements, and this transaction is committed when the statement completes. The isolation level of this transaction will be the current isolation level, which defaults to READ COMMITTED. Certain statements overwrite the current isolation level and enforce READ COMMITTED (eg. RECEIVE).
If your SqlCommand executes a batch (more statements) then each statement that access tables will create its own transaction.
The default autocommit of transactions is controlled by changing the SET IMPLICIT_TRANSACTION ON.
See Controlling Transactions for more details.