From Rows to Pages: The Hidden Chaos Behind SQL Server’s Sampling Methods


Introduction

Sampling data is a common requirement in many real-world SQL Server workloads. Whether you are trying to test a subset of data, preview records before an export, or build a small development copy of a table, sampling becomes a go-to tool. SQL Server offers an operator called TABLESAMPLE, which looks simple and promising at first. When someone writes a query like select top 100 from Orders tablesample 10 percent, the natural expectation is that SQL Server will return a random 10 percent of the rows. Unfortunately, that’s not how it works.

<p data-start="324"