title: Select n random rows from SQL Server table
body: <p>I've got a SQL Server table with about 50,000 rows in it. I want to select about 5,000 of those rows at random. I've thought of a complicated way, creating a temp table with a "random number" column, copying my table into that, looping through the temp table and updating each row with <code>RAND()</code>, and then selecting from that table where the random number column &lt; 0.1. I'm looking for a simpler way to do it, in a single statement if possible.</p>
  
  <p><a href="http://www.sql-server-helper.com/tips/generate-random-numbers.aspx" rel="noreferrer">This article</a> suggest using the <code>NEWID()</code> function. That looks promising, but I can't see how I could reliably select a certain percentage of rows.</p>
  
  <p>Anybody ever do this before? Any ideas?</p>