Get random number of rows from SQL Server table
问题 I am trying to get 5 random number of rows from a large table (over 1 million rows) with a fast method. So far what I have tested with these SQL queries: Method 1 Select top 5 customer_id, customer_name from Customer TABLESAMPLE(1000 rows) order by newid() This method estimated I/O cost is 0.0127546 so this is very fast (index scan nonclustered) Method 2 select top 5 customer_id, customer_name from Customer order by newid() This method's sort estimated I/O cost is 117.21189 and index scan