Suppose you have a table in SQL Server as in the following:
Image 1.
You want to get 5 random records on every select request. Then use the following SQL Statement:
Image 1.
You want to get 5 random records on every select request. Then use the following SQL Statement:
- SELECT TOP 5 * FROM Employee ORDER BY NEWID()
Now see the result:
Image 2.
Now again execute the query:
Image 3.
Image 4.
Image 2.
Now again execute the query:
Image 3.
Image 4.
No comments:
Post a Comment