Page 1 of 1

Create a Random Number field

Posted: Fri Aug 28, 2009 11:12 am
by Eric
This command generates a random number field (called Random) and fills it with a 15-digit, unique random number:

Code: Select all

ON ERROR com_message=message()
alter table alias() add column random c(15)
REPLACE all random with PADL(allt(str(recno()))+allt(str(INT((90-65+1)*RAND( )+65)))+allt(str(INT((90-65+1)*RAND( )+65)))+;
PADL(ALLT(STR(INT((RECCOUNT()+1)*RAND( )+7))),15,"0"),15,"0")
Here is a 10 digit random number:

Code: Select all

ON ERROR com_message=message()
alter table alias() add column random c(10)
REPLACE all random with PADL(allt(str(recno()))+allt(str(INT((90-65+1)*RAND( )+65)))+allt(str(INT((90-65+1)*RAND( )+65)))+;
PADL(ALLT(STR(INT((RECCOUNT()+1)*RAND( )+7))),10,"0"),10,"0")