Why does a CHECK (Quantity > 0) happily store a row with no quantity? Three-valued logic, a small demo, and the NOT NULL fix.
DATEDIFF Counts Boundaries, Not Time: Getting Durations Right
A report can say one year of service after a single day. Here is why DATEDIFF does that, and what to use instead.
SQL SERVER – A Puzzle – Fun with NULL – Fix Error 8117
NULL is fun to ask about in interviews, since every answer I get is different. A short puzzle on NULL that raises Error 8117, and how to fix it.
SQL SERVER – Solution Part 2 – A Quick Puzzle on SQL JOIN and NULL – SQL Brain Teaser
Part 2 of the solution to my puzzle on SQL Join and NULL. Readers still email me answers every day, so here are more of the good ones they sent.
ANY and ALL: Comparing a Value to a Whole Subquery in T-SQL
One missing price is enough to make ALL return nothing while ANY returns rows. Here is how to see it, and how to ask the question more safely.
LIKE Character Ranges: [a-f], [^0-9] and Collation Traps
A bracket range sounds simple until the collation decides what sits between a and f. Test it once so a bad code never reaches your table.
SQL SERVER – Puzzle Involving NULL – Resolve – Error – Operand data type void type is invalid for sum operator
SELECT SUM over a lone NULL throws Msg 8117: Operand data type void type is invalid for sum operator. Here is why it happens and how ISNULL fixes it.






