My T-SQL style guide, tested instead of asserted.

Each post takes one rule and checks it against SQL Server: ISNULL truncation, NOT IN with a NULL, double-hyphen comments, COALESCE in a WHERE clause, COUNT and COUNT_BIG, nested transactions, NOLOCK, and snapshot isolation. The last two posts explain why I keep a style guide, and how a plan analysis skill showed me that the reason behind one of my rules was wrong.
- ISNULL Truncates Your Replacement Value; COALESCE Doesn’t
- One NULL in the List and NOT IN Returns Nothing
- Double-Hyphen Comments Can Comment Out Your WHERE Clause
- COALESCE in a WHERE Clause Costs You the Row Estimate
- COUNT Under the Hood
- A Nested COMMIT Does Not Commit Anything
- NOLOCK Returned a Balance That Never Existed
- The SET Succeeds and the Catalog Read Succeeds, Then Msg 3951
- Why I Keep a T-SQL Style Guide, and What Testing It Cost Me
- A Plan Analysis Skill That Refuses to Let You Cite Cost
Questions or corrections are welcome on Bluesky or LinkedIn. See all series on this blog.