View Full Version : Using ORDER BY NEWID()

02-28-2003, 09:51 AM
I'm looking at using ORDER BY NEWID() in my sql statement to generate random records from a database, like this:


Is this an efficient method for selecting from tables with less than 5,000 rows, or can anyone suggest a better approach.

DB is MS SQL Server 2000.

Roy Sinclair
02-28-2003, 02:35 PM
It seems to work ok but as for efficiency you'll have to use the performance tools to see if it's creating a burden on the server.

03-01-2003, 01:25 AM
If you've got less than 5,000 rows, I think pretty much anything will work, unless you've got other databases on the server that are getting hit hard.

That isn't very much data as far as SQL Server is concerned - but it's still a good idea to do things right - so I'd definitely look at the server performance tools as Roy suggested.


03-03-2003, 07:52 AM
Thanks guys, this does fit with what I was thinking. Using the NEWID() may be inefficient for very large tables as the db has to generate a unique ID for each row, but as you say 5,000 is few.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum