Code RoomDirty read with NOLOCK hint
HardPrep Room Coding #1849

Dirty read with NOLOCK hint

Code reviewDatabases & SQLSenior–Staff~28 min

Review this SQL (T-SQL / SQL Server) inventory-availability check used at checkout.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 28 min
Mark a line and say what kind of problem it is.0 findings
1CREATE PROCEDURE dbo.CanFulfill @sku INT, @qty INT, @ok BIT OUTPUT
2AS
3BEGIN
4 SET @ok = 0;
5 SELECT @ok = CASE WHEN on_hand >= @qty THEN 1 ELSE 0 END
6 FROM dbo.inventory WITH (NOLOCK)
7 WHERE sku = @sku;
8END
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.