Scrivio Interview library
DesignAdvanced5 min read · updated 12 November 2026

Teams use NOLOCK hints widely in SQL Server queries to avoid blocking. What risks does that carry, and what platform-level policy would you set instead?

NOLOCK means READ UNCOMMITTED for that table: the query can return data that is later rolled back, and because it may scan in allocation order without locks, it can skip rows or read the same row twice when pages split during the scan. It hides blocking rather than fixing its cause. Instead I would make RCSI the standard for OLTP databases, ban NOLOCK through code review and a linter with a documented exception process, use SNAPSHOT isolation for reports that need one consistent view, move heavy reporting to readable secondaries in availability groups, and monitor the version store and long-running transactions as part of the platform.

Why this question is asked

In many SQL Server shops, WITH (NOLOCK) is sprinkled on almost every query. It usually started as a quick fix for a blocking incident years ago and became habit. Most of the time nothing visibly goes wrong, which is exactly what makes it dangerous: the wrong answers it produces are rare, silent and hard to reproduce. Interviewers ask this to see whether we understand the actual risks and can replace a habit with a platform policy. In this answer, we will recap what NOLOCK does, show the three ways it returns wrong results, explain why it only hides the problem, and then set out the policy that replaces it.

1A Quick Recap of What NOLOCK Does

NOLOCK is a table hint equivalent to READ UNCOMMITTED for that table. The query takes no shared locks and ignores the exclusive locks of writers, so it never waits. That is why it seems to cure blocking. But it also means the query reads whatever is on the page at that instant, committed or not, consistent or not.

2Wrong Result 1: Reading Data That Never Existed

The first risk is the dirty read: reading a change that is later rolled back.

SQL
-- Session 1
BEGIN TRAN;
UPDATE accounts SET balance = balance - 1000000 WHERE id = 42; -- a mistaken update
-- Session 2
SELECT balance FROM accounts WITH (NOLOCK) WHERE id = 42; -- -999000, never committed
-- Session 1
ROLLBACK; -- the real balance is 1000

If session 2 was a fraud check, a payment decision or a cache refresh, it has acted on a value that never existed. The same thing happens with half-finished multi-row transactions: a NOLOCK query can see an order's new header but not its new lines.

3Wrong Results 2 and 3: Skipped and Duplicate Rows

The less known risks come from how the scan moves through the table. Without locks, SQL Server may read the table in allocation order, the physical order of its pages, instead of index order. If a concurrent insert or update causes a page split while the scan is running, half of a page's rows move to a new page. If the new page lies behind the scan's current position, those rows are never read. If it lies ahead, rows the scan already read are read again.

So a SUM over a table can be wrong even when every transaction committed and nothing was rolled back. A report can count an order twice or not at all. Occasionally the query even fails with error 601, could not continue scan with NOLOCK due to data movement.

Step throughA page split during a NOLOCK scan
NOLOCK scanPage 10Page 11Inserting session
read rows 1-50 on page 10
insert into page 10: page is full
split: rows 26-50 move to page 11
read page 11: rows 26-50 again
result counts 25 rows twice

5 messages in order. Play them, or step through them one at a time.

The same split can also move rows behind the scan, so they are missed instead.

4Why It Hides the Problem

Blocking is a symptom. It tells us that transactions are long, that queries scan more than they need, or that indexes are missing, so readers and writers touch the same pages for too long. NOLOCK silences the symptom, and the causes remain: long transactions still hold locks against other writers, missing indexes still make queries slow, and the next blocking incident appears on a query nobody marked. Meanwhile the team gets used to accepting results that are occasionally wrong.

5The Platform Policy

The policy replaces the reason people reach for NOLOCK. First, RCSI is enabled on every OLTP database by default. Under RCSI, normal READ COMMITTED reads never wait for writers and always return committed, statement-consistent data, which is what NOLOCK users wanted in the first place. This alone removes most of the motivation.

Second, NOLOCK and READ UNCOMMITTED are banned in new code. Code review checklists include it, and a linter in the build fails on the hint in SQL files, stored procedures and Java strings, with a documented exception process for the rare legitimate case, such as a monitoring query on a very large table where an approximate count is acceptable. Existing hints are removed database by database after RCSI is switched on there.

Third, reports that run several queries and need them to agree use SNAPSHOT isolation, which gives the whole transaction one consistent view without blocking. Fourth, heavy reporting moves off the primary to readable secondaries in Always On availability groups, so its I/O and CPU do not compete with OLTP. Readable secondaries need Enterprise Edition and licences for the secondary, which belongs in the cost discussion.

Fifth, the platform monitors what versioning costs: tempdb or version store size, the oldest active transaction, and long-running queries, with alerts. That replaces the invisible risk of NOLOCK with visible, managed costs.

SQL
-- A simple CI check (example): fail the build on the hint
-- grep -rniE "with *\( *nolock *\)|read uncommitted" src/ db/ && exit 1
What replaces NOLOCK
NeedOld habitPolicy
Reads must not wait for writersNOLOCKRCSI on every OLTP database
Multi-query report must agreeNOLOCKSNAPSHOT isolation
Heavy reporting loadNOLOCK on the primaryReadable secondary in an availability group
Approximate monitoring queryNOLOCKAllowed by documented exception
Catching regressionsNoneLinter, review checklist, version store alerts

6Follow-up questions

Is NOLOCK ever acceptable?

Yes, rarely, when an approximate answer is truly fine and the query must never wait, such as a dashboard showing roughly how many rows a huge staging table has. The policy allows it with a documented exception, so the choice is deliberate and visible, not a habit.

Does removing NOLOCK after enabling RCSI change results?

It makes them correct. Queries will now return only committed, consistent data. In rare cases code depended on seeing uncommitted rows, for example a progress screen reading an open batch, and those need redesigning, which is another reason to remove hints gradually with testing.

Why not just use SNAPSHOT everywhere instead of RCSI?

SNAPSHOT has to be requested per transaction, so every piece of code would have to change, and writes under SNAPSHOT can fail with update conflict error 3960, which needs retries. RCSI improves the default level without code changes, and SNAPSHOT is kept for the reports that need it.

7Conclusion

In this answer, we saw that NOLOCK reads uncommitted data and, because it scans without locks, can skip rows or read them twice during page splits, while only hiding the causes of blocking. The policy that replaces it enables RCSI for OLTP databases, bans NOLOCK in reviews and linters with a documented exception path, uses SNAPSHOT for consistent multi-query reports, moves heavy reporting to readable secondaries, and monitors the version store and long transactions as part of the platform.

What to say in the interviewAbout 90 seconds aloud

Open with

NOLOCK is READ UNCOMMITTED for that table, and it carries three risks. It returns dirty data, values from transactions that may roll back, so a decision can be made on a balance that never existed.

Then, if they want more

And because it scans without locks, sometimes in allocation order, a page split during the scan can move rows behind it, so they are skipped, or ahead of it, so they are read twice. That means sums and counts can be wrong even when every transaction committed.

It also hides the real problem: blocking is caused by long transactions, big scans or missing indexes, and those remain. As a platform policy, I would enable READ_COMMITTED_SNAPSHOT on every OLTP database, because that gives teams what they wanted from NOLOCK, reads that never wait, but with committed and statement-consistent results.

Then I would ban NOLOCK and READ UNCOMMITTED in new code through review checklists and a build linter, with a documented exception process, and remove existing hints database by database after RCSI is on.

Reports that run several queries and need them to agree use SNAPSHOT isolation, and heavy reporting moves to readable secondaries in availability groups, accepting the licence cost. Finally the platform monitors the version store, tempdb and long-running transactions, so the cost of versioning is visible and managed.

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 "Teams use NOLOCK hints widely in SQL Server queries to avoid blocking. What risks does...": https://scrivio-interview-library.netlify.app/databases/oracle-and-sql-server/5e479a9655/