Jonathan Gennick and Ales Spetic's Transact-SQL Cookbook (O'Reilly, 2002) is a
collection of SQL recipes for common problems: pivoting data, generating sequences,
computing running totals, finding gaps in ranges. It was written against SQL Server 2000,
before recursive CTEs, window functions, or the PIVOT keyword existed.
The recipes are correct. Most are now strictly inferior to what's possible today; harder to read, slower to execute, and unfamiliar to anyone who learned SQL post-2005.
// what this series is
Each post shows the original recipe and a modern rewrite. Where dialect syntax differs meaningfully, each engine gets its own block.
- T-SQL - SQL Server 2019+
- PostgreSQL - 14+
- Oracle - 19c+
- SQLite - 3.25+
If the modern syntax is identical across all four, only one example is shown.
// what this series is not
Not a SQL tutorial. Assumes you can read a query. Not a criticism of the book; the problem framing is still worth reading. If a window function replaces twenty lines of CASE expressions, use the window function.