Easy Way To Randomize Records

There are some fancy ways to create random records. Some formulas/codes generate random numbers between 0/1, some others pick every Nth record. This method is very simple and works by creating a new ID string for each record and then sorting by that ID. All that one needs to do is to write ORDER BY NEWID(). Perfect for a quick spot check of data pulls.

This entry was posted in Interesting SQL Patterns and tagged , , . Bookmark the permalink.