The SET Succeeds and the Catalog Read Succeeds, Then Msg 3951
Snapshot isolation is the answer to most of the problems WITH (NOLOCK) gets used for, which I covered in . Readers stop waiting for writers, and unlike read uncommitted, everything they read was actually committed….
NOLOCK Returned a Balance That Never Existed
WITH (NOLOCK) gets added to queries for one reason: something was slow, or something was blocked, and the hint made the query run. It does make blocking stop. What it gives up in exchange is…
A Nested COMMIT Does Not Commit Anything
A procedure that opens its own transaction is fine on its own. Call it from another procedure that already opened one and the arithmetic stops matching your intent. SQL Server does not have nested transactions….
COUNT Under the Hood
COUNT() and COUNT_BIG() do the same thing: they return the total number of rows in your result set, or the number of rows-per-group with GROUP BY. Only COUNT_BIG() works when there are more than 2,147,483,647…
COALESCE in a WHERE Clause Costs You the Row Estimate
Optional filter parameters are everywhere in reporting procedures. Pass a value and you want that value; pass NULL and you want everything. There are two common ways to write it, and I have carried a…
Double-Hyphen Comments Can Comment Out Your WHERE Clause
-- and /* */ both comment out T-SQL. The difference is where they stop. /* */ stops where you close it. -- runs to the end of the line,[2] and if there is no end…