Gustav Brock
gustav at cactus.dk
Fri Aug 27 12:46:54 CDT 2004
Hi John OK, that's a lot or records. You could use RAND() to pick the sample. It would require one loop through the table not even selecting on the primary index. Create an expression with RAND() returning numbers between 1 and 100. Select on this equal any value (from 1 to 100, it doesn't matter per definition) and you will have a recordset of count/100 records. I can't imagine any way to do this faster. /gustav >> Does anyone have a strategy for pulling every Nth record? My client wants >> to pull every 100th record into a dataset for analysis, to speed things up I >> am guessing. > To speed up what? Analysis on a sample only and not on the full set? > If so, you could select by "Random Between 1 To 100" = 1. I am working on a SQL Server database of about 65 million records. We need to pull a subset of those for doing counts of data in specific fields. Trying to do that analysis on the entire 65 million records just won't work at least in anything close to realtime. Thus we literally want to pull every Nth record. If we pulled every 100th record into a table that would give a sampling of 650K records to run this analysis on. That still won't be lightning fast but at least doable.