### Background

I have a front-end with a list of items with infinite scrolling, and I fetch pages of items by specifying the page limit and offset.

### Problem

Apart from simply ordering the result by some of the columns, I would like to add a "random" option. The thing is, I don't want repetitions, so I need to have the entire dataset permutated before doing the limit and offset, and I need to be able to get the same permutation as long as I supply the same seed.

### What I tried

A naive approach was to write a table-valued function that takes an `int` seed and uses it in the `ORDER BY` clause like so:

```sql
SELECT *
FROM dbo.Entities e
ORDER BY HASHBYTES('MD2', e.Title) ^ @seed
OFFSET 0 ROWS
FETCH NEXT (SELECT COUNT(*) FROM dbo.Entities) ROWS ONLY

```

This seemed to work well at a first glance, but it turned out it's not very "volatile" for the lack of better word - it becomes more visible with sparse result sets, where most seeds (chosen randomly from between 0 and 2147483647) yield the same order.

I thought I would get better results by hashing the seed as well, but SQL Server doesn't allow me to XOR two `varbinary` variables. Am I even looking in the right direction? Are there any performance considerations that I should be making and I might not be aware of?