Does anyone have a query that will select n number of random rows from a SQL Server CE 4 table?
Asked
Active
Viewed 317 times
1 Answers
3
Have you tried:
SELECT TOP N * FROM table ORDER BY NEWID()
NEWID causes a GUID (semi-random identifier) to be created for each row in the result set and sorting by it ought to give you N fairly random results.

Paul Sasik
- 79,492
- 20
- 149
- 189
-
I thought I'd tried `NEWID()` before I asked the question and it didn't work, so I presumed it wasn't available with CE. I've just tried it again though and it works perfectly, so I was obviously making a silly mistake elsewhere. Thanks for the help! – ipr101 Feb 12 '12 at 21:07