Updated: 10/1/2004; 5:55:29 PM.
braindump
People, places, and things of interest to me. A place to upload things I might forget later.
        

Thursday, September 30, 2004

I was pretty frustrated with SQL today attempting to get back five random rows from a table.

The problem is that the RAND() function only runs once per execute - not once per row.

My solution around it:

SELECT TOP 5 * FROM tableName ORDER BY NewID()
12:44:40 AM    comment []

© Copyright 2004 nick gaydos.
 
September 2004
Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Aug   Oct


Click here to visit the Radio UserLand website.

Subscribe to "braindump" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.