T-SQL reference › NOLOCK
WITH (NOLOCK) in SQL Server: why people put it on, and why you should not
NOLOCK means “do not wait for other people’s locks.” You can read a value that never committed. Reports go out. Then the number changes.
What you will see in old scripts
SELECT order_id, total_amount
FROM Orders WITH (NOLOCK)
WHERE order_date >= CAST(GETDATE() AS date);
Someone put it on because a report blocked a checkout, or the other way round. The fix is usually a better index or a replica, not dirty reads on finance numbers.
NOLOCK on a total you will send
If James will stand up the number, wait for the committed rows.
Try it on Harbour & Co
Tom Gallagher (Warehouse Lead) needs this now: “For the ops meeting: how many orders and how much revenue in each status?” Write the query, run it, send the results. On the paid plan.
Take the ticket →Learn it on a real ticket
Monday is free on WorkSQL. A colleague’s ticket lands, you write the T-SQL, we mark it. No videos. Five minutes.
Clock in free See Monday’s tickets