Krunal Mevada

Because there’s always more to learn

September 2008 - Posts

Getting random records from database table

Recently, in one project i need to get random records from sql server table and i found a good way to do same.

SELECT TOP <n> <column list> 
FROM <table>
WHERE <criteria>
ORDER BY NEWID()

The main function is NEWID() which return GUID.
Ex. Select Top 10 * From Employees Order By NEWID()  

Cheers !!
Krunal
Posted: Sep 27 2008, 12:48 AM by krunalm | with no comments
Filed under:
My first post on http://weblogs.asp.net/

Hello all,

This is my first post on http://weblogs.asp.net/

I m so excited about this.

I'll update and share the best things in technology, that i can.

Thanks,

Krunal Mevada

Posted: Sep 26 2008, 09:36 AM by krunalm | with no comments
Filed under:
More Posts