The graphical plan appeared: a thick arrow from a Clustered Index Scan, a Hash Match spilling to tempdb, and the dreaded yellow warning triangle: "Missing Join Predicate."

I wrote a query to unpivot a decade of quarterly sales:

The rest of the team had gone home hours ago. Only the hum of cooling fans and the faint blue glow of monitor screens kept me company. Tonight’s target: a legacy financial database running on SQL Server 2014. The company called it "Project Phoenix" – rebirthing old data into new dashboards. I called it a headache.

The Night the Database Spoke

But the server hummed a little quieter that day. And somewhere in the logs, a 2014 query plan smiled. Tools age, but fundamentals don't. Execution plans, indexing, statistics, and parameter sniffing – SSMS 2014 forced you to know them. And knowing them still saves the day.

SELECT CustomerID, Quarter, Revenue FROM Sales.FactQuarters UNPIVOT (Revenue FOR Quarter IN ([Q1_2014],[Q2_2014],[Q3_2014],[Q4_2014],...,[Q4_2024])) AS unpvt; The little red squiggly line appeared under UNPIVOT . SSMS 2014’s parser didn't highlight syntax errors in real-time – but the did something worse when I pressed F5 : Msg 102, Level 15, State 1, Line 5 Incorrect syntax near 'UNPIVOT'. I laughed. Of course. SQL Server 2014 supports UNPIVOT, but someone had changed the database compatibility level to 90 (SQL Server 2005). A trap.

SET STATISTICS TIME, IO ON; EXEC Dashboard.GetMonthlyReport @Year = 2024; Output: Table 'FactSales'. Scan count 1, logical reads 342, physical reads 0 SQL Server Execution Times: CPU time = 312 ms, elapsed time = 407 ms.