Compare EXISTS, IN, and JOIN for semi-joins, prevent duplicate customer rows, and handle NULL safely in exclusion queries.
DELETE TOP With ORDER BY: Removing the Oldest Rows First
Use DELETE TOP safely through an ordered CTE, preview oldest rows, apply a supporting index, and remove eligible rows in bounded batches.
Optimizer Timeouts: Reason for Early Termination in a Plan
Diagnose optimizer early termination in SQL Server plans, find cached timeouts with XML, and simplify queries using measured evidence.
Turning a Business Question Into a Query: Define the Metric First
Turn a business question into a tested T-SQL metric with explicit time zones, cancellations, returns, and a hand-checked sample.
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.
Letting an LLM Query SQL Server Safely: A Read-Only Login and Guardrails
Let an LLM query SQL Server through a restricted login, approved views, enforced row filtering, execution limits, and query auditing.
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.







