How to get Random Records from SQL Server Database Table

Some times for high volume of records we can not show all records to the user. But for example or case by case we need to show random records for SQL server Table. Here in this article I will show you how you can choose random records from a large result set.

Consider a Table like below:
tblstock

Now we want to show Top 3 Random Records:

SELECT TOP 3 * FROM tblStock ORDER BY NEWID()

Output:
Show Random Records rows SQL server
Note: You can apply condition or grouping in usual way.

Posted in Database, SQL Server

Leave a Reply

Your email address will not be published. Required fields are marked *

     

*