Data source will contain approx. 5000 records.
I know that it is possible to order data randomly with orderby newid()
. But data to be sorted should be paged. That means page n can not contain records from previous pages (n-1, n-2 etc). Now I think I have 2 ways to go: ordering in database, or in memory (because 5000 records is small enough to hold it in in-memory cache).
For option 1 (sorting in db) I am not sure if it's possible because data should be paged. Is it possible if yes how? For option 2, are there any good algorithms (good is performant and highly random sorter) to order data in memory ? How would you go in this scenario: ordering in memory or in database, why?
You can use pseudorandom numbers in TSQL to generate a reproducible list of randomized values.
Removing the comment delimiter from the calculation of
@Seed
will cause the sequence to vary for each new value of@LastLogin
.