This SQL Server 2025 cheat sheet puts the T-SQL I use every day on four printable pages. Every query ran on SQL Server 2025 first, and all the scripts are in the post. It covers joins, window functions, regular expressions, JSON, indexes, backups and SSMS shortcuts.
Erdős Unit Distance Problem: What It Is and What AI Found
The Erdős unit distance problem asks how many pairs of points can sit exactly one unit apart. Paul Erdős guessed the answer in 1946, and the guess stood for eighty years. In May 2026, an OpenAI model found a counterexample. I checked the grid trick behind it in SQL Server, spatial queries included.
Outdated Statistics in SQL Server: The Optimizer Is Planning for Last Year
Outdated statistics in SQL Server can slow a query even when its code has not changed. On SQL Server 2025 with the legacy estimator, a stale statistic sent one join to 120,043 logical reads, and a targeted update brought it down to 18,220. Auto update helps, but it waits for a threshold, it samples, and it knows nothing about the rows that arrived today.
Preparing Time Series Features in T-SQL: Lags and Rolling Windows
Prepare time series features with LAG, prior-day rolling windows, calendar flags, and gap boundaries that prevent accidental continuity.
A Simple Linear Regression Trend Line in T-SQL
Calculate linear regression slope, intercept, monthly predictions, and R-squared in T-SQL while keeping extrapolation limits clear.
MATCH Clause in SQL Server Graph Tables: Query Relationships
The MATCH clause finds rows in SQL Server graph tables by describing the path between them. The small graph runs one hop, two hops, a shared skill and a SHORTEST_PATH query, compares the plain join, and shows what the MATCH clause does not allow.
Data Binning in T-SQL: Fixed Width, NTILE, CASE, DATE_BUCKET
Data binning turns a column of numbers into a few groups you can count and chart. This post runs four T-SQL methods on the same orders on SQL Server 2025: fixed width, NTILE, CASE ranges and DATE_BUCKET. It shows what each method tells you and one trap with BETWEEN.







