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
 Transact-SQL (2000)
 select random 2 records

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2007-02-12 : 02:56:51
how can I select a random 2 records from a query?
can i do this in sql?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-02-12 : 03:06:23
Yes

select top 2 * from yourtable order by newid()



KH

Go to Top of Page

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2007-02-12 : 03:26:58
but i don't wnat it ordered by my id
-- i want each time a different 2 records to show up - is this possible?
Go to Top of Page

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2007-02-12 : 03:41:45
never mind i tried it -- id didn't realilze newid was a sql - thanks
Go to Top of Page
   

- Advertisement -