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)
 SQL - get a random record

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-02-26 : 10:48:30
Jørn Aakre writes "Looking at the stuff you got here, I very soon realised that this was not good enough and I had to make my own.

Anyway, here is what I came up with:

SELECT TOP 1 *,sin(rand()*2*3.14159+TableIdentity) as Random FROM Table ORDER BY Random

Replace Table with tablename and TableIdentity with your identity column. This will ONLY work "good" with 1 record.

Any feedback to this aproach?

- jørn"
   

- Advertisement -