T-SQL Query Exercise: Generate Big Spills


When I was testing SQL Server 2025’s new ability to limit TempDB usage with Resource Governor, I wrote a few fun diabolical demos. One of them was to generate giant spills to TempDB, quickly.

When you’re looking at an actual (not estimated) query plan, and you see a yellow exclamation point on a sort operator, that means:

SQL Server made a guess about how much memory it would need to accomplish that sort The amount of data coming into the sort wildly exceeded SQL Server’s plans SQL Server resorted to writing that data to TempDB: aka, the data