Just order the table by a random number and obtain the first 5,000 rows using TOP.
SELECT TOP 5000 * FROM [Table] ORDER BY newid();UPDATE
Just tried it and a newid() call is sufficent - no need for all the casts and all the math.
Just order the table by a random number and obtain the first 5,000 rows using TOP.
SELECT TOP 5000 * FROM [Table] ORDER BY newid();UPDATE
Just tried it and a newid() call is sufficent - no need for all the casts and all the math.