Q:

Repeatable random sort on SQL-Server

I was wondering if anyone knew of how to perform a repeatable random sort on MS SQL Server.
I have achieve the same on other DB Platforms via setting a seed value on the random function:
MySQL/MariaDB: ORDER BY RAND(?);
Oracle: EXEC DBMS_RANDOM.SEED(?); ORDER BY DBMS_RANDOM.VALUE;
Postgres: SELECT SETSEED(?); ORDER BY RANDOM();

However, I can't find the equivalent on SQL-Server.
Doing some research, I tried the syntax TABLESAMPLE(100 PERCENT) REPEATABLE(Y). But TABLESAMPLE doesn't seem to give me the rows back in any random order.
SQLFiddle: http://sqlfiddle.com/#!3/d50dd/30

A:

This is probably not the best solution for large tables, but it will work for most smaller tablesets.
ORDER BY RIGHT(STR(RAND(id + seed), 18, 18), 1);
Explanation on what this does:

We generate a random float value based on the row_id + seed value passed. This float value is 18 digits in length.
Convert the random float value to a string which lets us use T-SQL native string functions on the value.
Use the T-SQL RIGHT() function to grab the last digit of the random float value. USE that to ORDER by.

I am not sure how performance will be, but I anticipate this to be pretty average to bad for large data sets.
SQLFiddle: http://sqlfiddle.com/#!3/d50dd/95

