Create a Random Number field

Build your list of AccuZIP6 commands by requesting commands and sharing commands with other users

Moderators: Chrissy, Steve, Terry, Donna, Dave, Eric, MartyH, Kristen, Geoff, Vince

Post Reply
User avatar
Eric
Moderator
Posts: 1910
Joined: Tue Sep 19, 2006 3:29 pm
Contact:

Create a Random Number field

Post by Eric » Fri Aug 28, 2009 11:12 am

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")
Chat with an AccuZIP6 technician weekdays from 7-4 PST with AccuZIP6 Live Online Support

Post Reply