Random rows

  • I need to select random 5% rows from 100 records. The Select Top (5) percent gives me the first 5 rows. I want a random 5% but not in order. Any suggestions ?

  • Just select your top 5 percent rows and order by NEWID()

    To help us help you read this[/url]For better help with performance problems please read this[/url]

  • Even easier use the TABLESAMPLE funciton in sql 2005

    select * from MyTable tablesample(5 percent)

    there are some limitations on this though check BOL, the smaller the number of rows in your table the less accurate the % sample will be.

  • thanks but this did not get 5%

  • thanks..this worked

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply