Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Getting 14 random records
Message
 
 
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:
01503999
Vues:
47
>>What would be the way to select 14 random records from a table?
>
>select top 14 * from myTable order by NewID()

This probably was not a very good advice, as
;with cte as (select top 14 ID from myTable order by NewID())
select T.* from myTable inner join cte on T.ID = cte.ID
could have been better.

Check http://sqlblog.com/blogs/paul_white/archive/2011/02/23/Advanced-TSQL-Tuning-Why-Internals-Knowledge-Matters.aspx
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform