To use this function you will need a populated table of primes. See script: http://www.sqlservercentral.com/scripts/Prime+Numbers/155286/
Theoretically the maximum number that can be guaranteed to be factorized is the maximum value of a bigint (9223372036854775807) but to guarantee factorisation you will need all primes up to the square root of that value in the dbo.Primes table.
To factorise any number up to 100 trillion you will need a Primes table with all prime less than 10,000,000. To do this use the the script here to generate a table of 10 million primes.
Sampe call to factorise a number:
SELECT * FROM dbo.PrimeFactors(99999820000081)