Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting 14 random records
Message
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01382524
Message ID:
01503999
Views:
46
>>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
Previous
Reply
Map
View

Click here to load this message in the networking platform