Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting 14 random records
Message
 
 
À
17/02/2009 20:14:46
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01382524
Message ID:
01382546
Vues:
57
>>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform