I want to use RANDRANGE to generate a four digit number anywhere from 0001 to 9999. The problem is that the resultant number ends up less than four digits because, as an example, 0500 is reduced to 500 when displayed to the user as a variable and when saved to the database. Seems the leading 0 is removed.
I need four digits only. I realize I can set the random number 1000, 9999 but that does not feel right for the way want to do it.
I doesn't seem to make much difference what data type I use in sql2000. init, smallinit, numeric, or varchar as I'm currently using. So, how do I solve this and what would be the best data type to save space in a large database?
<!--- These return only three resultant numbers if the number generated begins with a zero. --->
<cfset MYNUMBER = RandRange(0001, 9999)>
<!---or even --->
<cfset PRIZE1 = #numberFormat(randrange(0,9999), "0000")#>