Randomize Query in SQL

/ Published in: SQL
Save to your folder(s)

Sometimes you want to return a bunch of data from a table, but you want it coming back in a random order. Maybe it's for keeping some content on a home page fresh. Here's how:

Copy this code and paste it in your HTML
  1. SELECT TOP 10 * FROM [someTable] ORDER BY NEWID()

URL: http://codefinds.blogspot.com/2008/08/randomize-query-in-sql.html

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.