Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Selecting random records

Author  Topic 

drakull
Starting Member

12 Posts

Posted - 2001-03-03 : 13:13:05
Is there a way to create a query to select random records in SQL Server?

I have a TIPS table and want to select 3 random records to show at the site's main page each time it's viewed.

Just in case: i use IIS 5.0 and SQL Server 7.0

I've looked at the articles on selecting ramdom records but they have a flaw... the code only works if the ID field is sequential... what if the ID # 34 was deleted and the random number returned is 34???

The article "Returning Rows in Random Order - Part II - Revenge of the Randomizer" talks about it but it's workarounds are too much complicated...

----------
Henrique

Edited by - drakull on 03/03/2001 13:32:47
   

- Advertisement -