Use DELETE TOP safely through an ordered CTE, preview oldest rows, apply a supporting index, and remove eligible rows in bounded batches.
SQL SERVER – Techniques for Retrieving Random Rows
This post will explore various techniques to retrieve random rows in SQL Server and analyze their performance and randomness characteristics in depth.
TOP N Sort: Why a Small TOP Still Reads the Whole Table
Explain TOP N Sort, compare an indexed ordered access path, and align filter and sort keys before adding indexes for frequent requests.
Filtering on a Window Function Without QUALIFY in SQL Server
Filter window results without QUALIFY using CTEs and derived tables, compare TOP WITH TIES, and preserve partition and tie rules.
Top 1 and Index Scan: A Scan That Stops After One Row
Top 1 and index scan can sit in the same plan, and the scan still reads only a few pages. This post runs six queries on a table of 100,000 rows and reads their logical reads. It shows why TOP 1 reads three pages in one case and every page in another.
Top N Plus Others: Grouping the Rest Into One Row
Create top N plus others summaries with deterministic category ranking, one remainder total, stable labels, and explicit display ordering.
Top N per Group: Three Ways and Which Is Fastest
Compare top N per group with ROW_NUMBER, APPLY and a correlated subquery, define tie behavior, and measure plans with a supporting index.







