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 2005 Forums
 Transact-SQL (2005)
 how can i pick a random row from the given table

Author  Topic 

js.reddy
Yak Posting Veteran

80 Posts

Posted - 2007-12-13 : 01:33:46
Hi
I have a table called Mytable
How can i display a random row from that table by using select query

Thanks

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-12-13 : 01:34:59
[code]select top 1 *
from Mytable
order by newid()[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

js.reddy
Yak Posting Veteran

80 Posts

Posted - 2007-12-13 : 01:50:24
Thank you Khtan.

quote:
Originally posted by khtan

select top 1 *
from Mytable
order by newid()



KH
[spoiler]Time is always against us[/spoiler]



Go to Top of Page
   

- Advertisement -