Create Random Number up to 50 Digits and Store in Varchar Does anyone have code; looking for a random number function generator.
I would just supply with a variable length @NumberLength = 50, etc.
It can create numbers up to 50 digits, and store in varchar. (Bigint does not store this high)
I am using Floor Rand, Floor, NewId(), still not receiving answer, that exceeds 12 digits.

If anyone has a solution, that would be great. I need to randomize a column in table.

Thank you,

Note: Needs to be in a function, functions cannot accept NewID or rand() for some reason, so I sometimes utilize views.
If random number is used again, no issue, we can have little bit repetition.
Here's one approach (demo).

Create a view as CRYPT_GEN_RANDOM won't be allowable in a function

CREATE VIEW dbo.LongRandom
AS
  SELECT CONVERT(VARCHAR(500), CRYPT_GEN_RANDOM(500), 2) AS random_hex_string


And then call it in a function and Replace all A-F with empty strings. The below uses TRANSLATE to map all B-F to A and a final REPLACE to remove all the As. 

You could also simply use 6 nested REPLACE (if you are on a version &lt; 2017 you will have to anyway)

CREATE FUNCTION dbo.reallyBigRandInt(@Length TINYINT)
RETURNS VARCHAR(50)
AS
  BEGIN
      RETURN
        (SELECT LEFT(REPLACE(TRANSLATE(random_hex_string,'BCDEF','AAAAA'),'A',''), @Length)
         FROM   dbo.LongRandom)
  END 


The string returned from the view is 10 times longer than the maximum final string required to make it extremely unlikely that removing these characters will leave insufficient characters.

Then select from that

SELECT dbo.reallyBigRandInt(50);


NB: You could also forgo the string parsing and just use CRYPT_GEN_RANDOM to generate three bigint that you glue together (without minus signs) but this is less random unless you are careful.

The maximum bigint is 9223372036854775807 so clearly there is a lower probability that the leftmost digit will be 9. Similarly there is a greater probability that the second character will be 1 or 0 than any other digit. As it is possible for the second character to be 3 only if the leading character is 0-8. Similar issues exist for the other positions but decline in importance as you move rightwards. 

If this isn't a problem for you you can concatenate the right most 17 digits of three bigints together to get a 51 character numeric string and then cut that down to the desired length.

CREATE VIEW dbo.RandomBigInt
AS
  SELECT CONVERT(BIGINT, CRYPT_GEN_RANDOM(8)) AS number


And function

CREATE FUNCTION dbo.reallyBigRandInt2(@Length TINYINT)
RETURNS VARCHAR(50)
AS
  BEGIN
      RETURN
        (SELECT RIGHT(RIGHT(FORMAT(number, 'D19'),17) + 
                      RIGHT(FORMAT(number, 'D19'),17) + 
                      RIGHT(FORMAT(number, 'D19'),17), @Length)
FROM  dbo.RandomBigInt)
  END