Wednesday, November 21, 2012

Sort table rows randomly in SQL Server

 

SELECT * FROM table
ORDER BY NEWID()


In the above example NEWID() creates a unique value of type uniqueidentifier for each row and sort the rows accordingly.


Below is the example for retrieving a single random record from a table


SELECT TOP 1 * FROM table
ORDER BY NEWID()


Happy coding…

1 comment:

  1. I have configured the nopcommerce 2.80 with CCavenue integration. Now the problem is, i am not getting redirected on the payment confirmation page on nopcommerce after successful transaction.

    ReplyDelete