Description:
#sqlserver #sqlserver
Get Random Rows From A Table
To retrieve random rows from a table, the SQL `newid()` function is often used. It assigns a unique identifier to each row, and when used in an `ORDER BY` clause, it randomizes the order of the rows. By selecting the top N rows after ordering by `newid()`, you can obtain random records. This method is widely used for scenarios like shuffling quiz questions, displaying random advertisements, or selecting random winners from a database. However, it may not be efficient for very large tables, as it requires reordering all rows.
Releated Video Display random images in asp.net
Share this link via
Or copy link
































