Toad World® Forums

Create a random sample of data from a view

I need to create a random sample of data from a very large view. Most of the built-in functions are not available in TOAD 3.7.

Why don’t you use SQL to do it for you? Here are two methods that will give random results:

select top 5000 * from [tablename] where ... order by newid()
select * from [tablename] tablesample(5000 rows) where ...

The second one is faster if you are on SQL Sever 2005 and up. You can also use %'s as in tablesample(5 percent) or top 5 percent. You can find this on