To retrieve random records from database table, we use
NEWID inbuilt function.
Execute below statement in Query window and we will get random two records from the
PersonalDetails table. If we need more or less, simply change the value of “2” in the query.
SELECT TOP 2 * FROM PersonalDetails ORDER BY NEWID()
Views: 1520 | Post Order: 55
NEWID() function randomly creates a unique ID and sort the record based on that and list TOP 2 records from the database table.