![]() |
|
|
By: Edgewood Solutions | Read Comments | Print Edgewood Solutions is a technology company focused on Microsoft SQL Server and founder of MSSQLTips.com. Related Tips: More |
|
Problem
Row versioning, although not specifically documented under that phrase, was around in previous versions of SQL Server but was reserved for maintaining data integrity (i.e., during UPDATE statements) and replication. In SQL Server 2005 Microsoft implemented row versioning as a method of gaining access to data, known as Snapshot Isolation Level is a means for read transactions to not block write transactions.
Solution
Snapshot isolation works by maintaining versions of modified data in a store (version store) in TEMPDB. Read transactions that run under the snapshot isolation level do not acquire shared locks, although schema locks are acquired for a brief period. Accessing data using snapshot isolation decreases the possibility of blocking transactions attempting to modify data. In addition, this isolation level facilitates index maintenance using the ONLINE option because reads are performed on the snapshot, not the table itself.
Enabling snapshot isolation is a two-step process:
1. Enable the READ_COMMITTED_SNAPSHOT option
2. Enable the ALLOW_SNAPSHOT_ISOLATION option
Both of these options must be ON in order to use the snapshot isolation level, otherwise you’ll get the following error:
When coding to use the SNAPSHOT ISOLATION LEVEL, use the SET TRANSACTION ISOLATION LEVEL statement:
Dynamic management views (DMV’s) are available that allow administrators to view information about row versioning:
Next Steps
| Share: | Share | Tweet |
|
![]() |
![]() |
Free SQL Server Learning |
|
privacy | disclaimer | copyright | advertise | about authors | contribute | feedback | giveaways | user groups Some names and products listed are the registered trademarks of their respective owners. Edgewood Solutions LLC | MSSharePointTips.com | MSSQLTips.com |