How to get Random Records from database table in SQL Server
Many times we want to show random values from table. Suppose we have 100 records and we want to 10 data values in one time but every time data should be different so we can use this code is very helpful. This code very useful when we want to show to bind any gridview for showing data for different different values.
So here we call NEWID() function
Script
Select top 3 * from table_name order by NEWID()
Out-Put:-
How to get Random Records from database table in SQL Server
Reviewed by NEERAJ SRIVASTAVA
on
11:44:00 PM
Rating:
No comments: