Показват се публикациите с етикет SQL Server. Показване на всички публикации
Показват се публикациите с етикет SQL Server. Показване на всички публикации

Tricks: How to get N random rows from a table in T-SQL

петък, 18 юли 2008 г.

Hi readers!

What is this blog post for?

Today I am going to present you the first post of my second series - Tricks. As I said before I will show "Technology Specific Tricks - short posts about something, which I have researched and which I want to preserve and share with you all."
The first one is about T-SQL


The problem - How to get N random rows from a table?



A little explanation - actually ORDER BY NEWID() sorts the rows in a random way. In our case we just take as much of the first as we need.


Conclusion

You just saw what you can expect from this type of posts.
Hope this helps!

 
Vesko Kolev's Blog : IDeveloper -