# Thursday, October 21, 2004
« Automated Testing and Bugs | Main | Bummer »

In my Design section today, I ranted a bit about automated testing and a trend I have noticed to avoid directly accessing a database for that testing. It didn't start out to be a rant, but rather a tip about grabbing a random SQL record.

Using an ORDER BY NewID() clause, you can either randomly order your data, or grab a random single row. I use the single row method to grab data for testing so I am not always testing the same value, or occassionally the random order when I am searching for a particular set of data using a cursor for really complicated testing. Here's the usage:

Random order:

SELECT * FROM Authors ORDER BY NewID()

Single Random Record:

SELECT TOP 1 * FROM Authors ORDER BY NewID()

Monday, December 27, 2004 10:56:29 AM (GMT Standard Time, UTC+00:00)
This is great !!!
Amrish
Thursday, August 04, 2005 8:57:29 PM (GMT Daylight Time, UTC+01:00)
In your free time, check out some information dedicated to casino on net http://casino-on-net.screwy-casino.com/
online casinos http://www.screwy-casino.com/
online casino gambling http://online-casino-gambling.screwy-casino.com/
slot machines http://slot-machines.screwy-casino.com/
roulette http://roulette.screwy-casino.com/
internet casino http://internet-casino.screwy-casino.com/
casino gambling http://casino-gambling.screwy-casino.com/
casino online http://casino-online.screwy-casino.com/
casino games http://casino-games.screwy-casino.com/
online casino http://online-casino.screwy-casino.com/
- Tons of interesdting stuff!!!
Comments are closed.