SUM integer values can exceed int even when each row fits. Cast each input to bigint before aggregation and keep NULL and empty-set behavior visible.
SQL SERVER – Easy Sequence of SELECT FROM JOIN WHERE GROUP BY HAVING ORDER BY
The sequence of SELECT, FROM, JOIN, WHERE, GROUP BY, HAVING and ORDER BY that I gave my new hires. Since then they ask me far fewer questions.
SQL SERVER – Explanation SQL SERVER Hash Join
How a Hash Join works in two phases, build and probe, why it suits large data sets without indexes, and why it needs an equijoin predicate.
How to Read a SQL Server Error Message
Read a SQL Server error message by separating its number, severity, state, procedure, and line, then preserve the context needed to investigate.
SQL SERVER – Recovery Models and Selection
SQL Server offers three recovery models: full, simple and bulk-logged. Here is when to select each one, based on how much data loss you can accept.
Normalization Jokes and the Normal Forms They Make Fun Of
Normalization jokes are funny because they are true. Here are the classics in my own words, and the first three normal forms they poke fun at.
SQL SERVER – LEN and DATALENGTH of NULL Simple Example
A common mistake is checking LEN(@var) = 0 for a NULL value. LEN and DATALENGTH of NULL both return NULL, not zero, as this simple example shows.
SQL SERVER – 2005 T-SQL Paging Query Technique Comparison (OVER and ROW_NUMBER()) – CTE vs. Derived Table
Paging in SQL Server 2005 with ROW_NUMBER: CTE vs. derived table. I compare both methods and show they give the same performance for common queries.










