t-sql-correctness
Writes T-SQL that returns the right answer on Azure SQL Database, and catches statements that return a wrong answer with no error: NULL compared using = or <> or NOT IN, ISNULL and COALESCE differing in return type, integer division truncating, a string variable declared with no length, and a session where QUOTED_IDENTIFIER is OFF. Also corrects PostgreSQL and MySQL habit (LIMIT, RETURNING, SERIAL, ILIKE, NOW(), true, false, double-quoted literals, TEXT columns, ON CONFLICT, USE) and the opposite mistake of avoiding syntax supported since 2025. Use when writing, porting or reviewing SQL, and for "why is that row missing", "why did NOT IN return nothing", "why is this average wrong", "how do I paginate", "how do I get the id I just inserted", "is this comparison case sensitive". Upserts are t-sql-upserts-merge, JSON t-sql-json-and-openjson, table design design-azure-sql-schema.
Pinned to revision eeb1c6867c2d, so it is the text this page describes rather than whatever the author pushed since.
Files
Every link opens the file at its source, pinned to the revision this page describes.