Scrivio Interview library
ConceptFoundations6 min read · updated 12 November 2026

What is the difference between SQL Server's READ COMMITTED with locking, READ_COMMITTED_SNAPSHOT (RCSI), and SNAPSHOT isolation?

Default READ COMMITTED on SQL Server uses shared locks, so a reader waits for a writer's exclusive lock and the two can deadlock. READ_COMMITTED_SNAPSHOT (RCSI) is a database option that makes the same READ COMMITTED level read row versions from the version store instead, so each statement sees the last committed data as of its start and never waits for writers. SNAPSHOT isolation is enabled with ALLOW_SNAPSHOT_ISOLATION and chosen per transaction; it gives one consistent view for the whole transaction, and an update to a row someone else changed since it started fails with error 3960.

Why this question is asked

SQL Server is unusual among the big databases: out of the box, its default isolation level still uses read locks, while Oracle and PostgreSQL use row versions. That single difference explains a lot of blocking and deadlock reports from Java teams. Interviewers ask this question to check that we know the three options, what each one promises, and what it costs. In this answer, we will recap shared locks, see how locking READ COMMITTED behaves, then look at RCSI and SNAPSHOT side by side, including how to use them from JDBC.

1A Quick Recap of Shared and Exclusive Locks

SQL Server protects data with locks. A writer takes an exclusive lock on each row it changes and keeps it until its transaction ends. A reader under locking READ COMMITTED takes a shared lock on each row or page while it reads it, and releases it as soon as it moves on. Shared and exclusive locks are incompatible: a reader cannot take a shared lock on a row that a writer holds exclusively, so it waits.

2READ COMMITTED With Locking: Readers Wait for Writers

Here is the behaviour with two sessions, using the default settings.

SQL
-- Session 1
BEGIN TRAN;
UPDATE orders SET status = 'SHIPPED' WHERE id = 7; -- exclusive lock on row 7
-- Session 2 (default READ COMMITTED)
SELECT status FROM orders WHERE id = 7; -- blocks, waiting for session 1
-- Session 1
COMMIT;
-- Session 2 now returns: SHIPPED

The reader never sees uncommitted data, which is the promise of READ COMMITTED, but it pays by waiting. Worse, a reader and a writer can deadlock: a report holds a shared lock on one page while waiting for a row the writer locked, and the writer needs that page. SQL Server kills one of them with error 1205. Notice also that statement-level consistency is weak here: because shared locks are released as the scan moves on, a long SELECT can see some rows before and some after a concurrent transaction.

3READ_COMMITTED_SNAPSHOT: The Same Level, Read From Versions

RCSI is a database option. Once it is on, every transaction that runs at READ COMMITTED, which is the default, stops taking shared locks. When a writer changes a row, SQL Server copies the previous committed version into the version store, which lives in tempdb, or in the user database itself when Accelerated Database Recovery is enabled on SQL Server 2019 and later. A reader that meets a row changed by an open transaction follows the version chain back to the last version committed before its statement started.

SQL
ALTER DATABASE shop SET READ_COMMITTED_SNAPSHOT ON WITH ROLLBACK IMMEDIATE;
-- Session 1
BEGIN TRAN;
UPDATE orders SET status = 'SHIPPED' WHERE id = 7;
-- Session 2 (still READ COMMITTED, no code change)
SELECT status FROM orders WHERE id = 7; -- PAID, immediately, from the version store

The application code does not change at all, which is why RCSI is so popular: it is a switch at the database level. Each statement sees a consistent picture as of its own start, the same model as Oracle's default. Writers still block writers, so two sessions updating the same row still wait for each other. Azure SQL Database turns RCSI on by default for new databases.

4SNAPSHOT Isolation: One View for the Whole Transaction

SNAPSHOT is a separate isolation level. The database must allow it first, and then each transaction asks for it explicitly. Every statement in a SNAPSHOT transaction sees data as of the moment the transaction started, so a report made of several queries sees one consistent picture.

The catch is writing. If a SNAPSHOT transaction tries to update a row that another transaction changed and committed after the snapshot transaction began, SQL Server cannot apply the change without losing the other update. It aborts with error 3960, a snapshot isolation update conflict, and the application must retry the whole transaction.

SQL
ALTER DATABASE shop SET ALLOW_SNAPSHOT_ISOLATION ON;
SET TRANSACTION ISOLATION LEVEL SNAPSHOT;
BEGIN TRAN;
SELECT SUM(total) FROM orders; -- as of the transaction start
SELECT COUNT(*) FROM orders; -- same moment, so the two agree
UPDATE orders SET status = 'ARCHIVED' WHERE id = 7;
-- if another session changed row 7 and committed after BEGIN TRAN:
-- Msg 3960: Snapshot isolation transaction aborted due to update conflict
COMMIT;
Three ways to read committed data
AspectREAD COMMITTED (locking)RCSISNAPSHOT
How enabledDefaultDatabase option, applies to READ COMMITTEDALLOW_SNAPSHOT_ISOLATION plus per transaction
Readers wait for writersYesNoNo
Consistent as ofNothing fixed, rows read over timeStart of each statementStart of the transaction
Write conflictWaitsWaitsError 3960, retry
Version store costNoneYesYes, kept longer

5Using Them From Java

With RCSI there is nothing to do in Java; the default level simply behaves differently. For SNAPSHOT, the Microsoft JDBC driver defines its own constant, because SNAPSHOT is not one of the standard JDBC levels.

Java
import com.microsoft.sqlserver.jdbc.SQLServerConnection;
conn.setAutoCommit(false);
conn.setTransactionIsolation(SQLServerConnection.TRANSACTION_SNAPSHOT); // value 4096
try {
runReport(conn);
conn.commit();
} catch (SQLException e) {
conn.rollback();
if (e.getErrorCode() == 3960) { /* retry the whole transaction */ }
else throw e;
}

In Spring, @Transactional(isolation = ...) only offers the standard levels, so SNAPSHOT is usually set on the connection in a small helper or through the data source, and the retry is handled like any other concurrency failure.

6Follow-up questions

Does RCSI make the database slower?

Writers do a little more work, copying old versions to the version store, and tempdb or the user database needs room for them. In return readers no longer wait, so for mixed OLTP and reporting workloads overall throughput usually improves. The cost to watch is version store growth during long transactions.

Which should a multi-query report use, RCSI or SNAPSHOT?

SNAPSHOT, because RCSI gives each statement its own moment, so two queries in the same report can disagree. A read-only SNAPSHOT transaction never hits error 3960, since that error only happens on writes.

Is NOLOCK the same as RCSI?

No. NOLOCK reads uncommitted data and can miss or double-read rows. RCSI reads only committed data from a consistent point in time. RCSI is the correct fix for blocking reads; NOLOCK only hides it.

7Conclusion

In this answer, we saw that SQL Server's default READ COMMITTED takes shared locks, so readers wait for writers and can deadlock with them. RCSI is a database option that keeps the READ COMMITTED level but reads row versions, giving each statement the last committed data as of its start without waiting. SNAPSHOT isolation, allowed by ALLOW_SNAPSHOT_ISOLATION and requested per transaction, gives the whole transaction one consistent view but fails with error 3960 when it updates a row others changed after it began. Azure SQL Database enables RCSI by default.

What to say in the interviewAbout 80 seconds aloud

Open with

There are three behaviours. SQL Server's default READ COMMITTED uses locks: a reader takes shared locks as it reads, so if a writer holds an exclusive lock on a row, the reader waits until the writer commits.

Then, if they want more

It never sees dirty data, but readers block on writers, and reports and updates can deadlock, which shows up as error 1205. READ_COMMITTED_SNAPSHOT, RCSI, is a database option.

With it on, the same READ COMMITTED level stops taking shared locks; writers copy the previous committed version into the version store, in tempdb or in the database with accelerated database recovery, and readers get the last version committed before their statement started. No code change is needed, and Azure SQL Database has it on by default.

SNAPSHOT is a separate level: the database allows it with ALLOW_SNAPSHOT_ISOLATION, and each transaction asks for it, in JDBC with SQLServerConnection.TRANSACTION_SNAPSHOT. Then every statement in the transaction sees the database as of the transaction start, which is what a multi-query report wants.

The catch is writes: if it updates a row someone else changed and committed after it began, it fails with error 3960 and must be retried. Writers still block writers in all three.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "What is the difference between SQL Server's READ COMMITTED with locking...": https://scrivio-interview-library.netlify.app/databases/oracle-and-sql-server/bd92e15e68/