You are here: Re: SELECT a random 10 records from table....easy newbie question « MsSQL Server « IT news, forums, messages
Re: SELECT a random 10 records from table....easy newbie question

Posted by Hugo Kornelis on 08/16/07 20:23

On Thu, 16 Aug 2007 03:39:49 -0700, WhytheQ wrote:

>This doesn't work:
>
>--****************************************
>USE myDatabase
>SELECT TOP 10 *
>FROM myTable
>WHERE NEWID()
>--****************************************
>
>..I know I need to use the function newID() to find random records -
>just don't know where it fits in the query (suspect the TOP will need
>to go from the above)
>
>Any help greatly appreciated
>J

Hi J,

Marcin's answer is correct. However, if you're on SQL Server 2005 you
can also use the new TABLESAMPLE option (see Books Online for the
details); this will probably perform better on large tables.

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация