DECLARE @RandMin Int, @RandMax int SET @RandMin = 1 SET @RandMax =150 SELECT CAST((@RandMax - @RandMin) * @Rand + @RandMin AS int)If you've Sql Server 2000 you can convert above code into UDF. To start the rand function off with a random number use something like
SELECT RAND( (DATEPART(mm, GETDATE()) * 100000 ) + (DATEPART(ss, GETDATE()) * 1000 ) + DATEPART(ms, GETDATE()) )