Code Room
Code reviewHardcr-g214
Subject Transaction isolationLevel Senior–Staff~28 minCommon in Databases & SQL interviewsIndustries Software development

Question

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.

Talk through your review
Code to reviewsql
CREATE PROCEDURE dbo.CanFulfill @sku INT, @qty INT, @ok BIT OUTPUTASBEGIN  SET @ok = 0;  SELECT @ok = CASE WHEN on_hand >= @qty THEN 1 ELSE 0 END  FROM dbo.inventory WITH (NOLOCK)  WHERE sku = @sku;END
Run or narrate your approach, then ask the coach.