Why just not use standard
Random.Next Method (Int32, Int32)[
^]?
Random rand = new Random();
int value = rand.Next(10000, 100000);
In case you are
generating random numbers in loop, you need to create instance of Random outside the loop (class static readonly field would be good for this).
In SQL Server you can use this code for getting
single random number:
SELECT 10000 + CAST(RAND() * (100000 - 10000) AS INT)
In case you need to generate
random number for each row of your result set, you have to use
NEWID[
^] instead of
RAND[
^] function:
SELECT 10000 + (ABS(CAST(CAST(NEWID() AS VARBINARY) AS INT)) % (100000 - 10000))