Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting 14 random records
Message
 
 
To
17/02/2009 20:14:46
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01382524
Message ID:
01382546
Views:
58
>>select top 14 * from myTable order by NewID()
>
>Thanks, this works.
>
>I assume this will always be optimized even on a two million records table.

As far as I know select TOP is not optimizable at all, but I'll verify just in case.

In any way, this is the technique to get random records in SQL Server.

Interesting read

http://technet.microsoft.com/en-us/magazine/2007.11.sqlquery.aspx

http://blogs.msdn.com/queryoptteam/
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform