select dbo.fx_getrandomnumber(500, 300, rand())FROM dbo.TallyWHERE N <= 10

select dbo.fx_getrandomnumber(500, 300, rand(CHECKSUM(NEWID())))FROM dbo.TallyWHERE N <= 10

SELECT ABS(CHECKSUM(NEWID()))%(500-300+1)+300 FROM dbo.Tally WHERE N <= 10

SELECT Number, COUNT(*) FROM (SELECT ABS(CHECKSUM(NEWID()))%(500-300+1)+300 AS Number FROM dbo.Numbers WHERE number <= 200) d GROUP BY Number ORDER BY Number

SELECT Number, COUNT(*) as NumberCountFROM (SELECT ABS(CHECKSUM(NEWID()))%(500-300+1)+300 AS Number FROM dbo.Numbers WHERE number <= 200) d GROUP BY Number ORDER BY Number

Number NumberCount ----------- ----------- 300 1303 1303 1305 2307 3307 3307 1309 2

SELECT Number, SUM(NumberCount), count(*)FROM (SELECT Number, COUNT(*) as NumberCount FROM (SELECT ABS(CHECKSUM(NEWID()))%(500-300+1)+300 AS Number FROM dbo.Numbers WHERE number <= 200 ) d GROUP BY Number ) d2GROUP BY NumberORDER BY Number

Number ----------- ----------- ----------- 301 4 3304 1 1307 2 2308 1 1309 1 1