Support 805.461.7300
Sales
Our Technology. Your Success.

Generate unique, random 4-digit numbers in a list

The command syntax below will generate a random 4-digit number in a field called "record" in your list. If your database has less than 10,000 names, this will create 0001-9999 in the database, with no value appearing twice. In reality it's simply indexing it on the "First" field, then assigning the record number based on that. Then it will re-index on zip, so that the number appears to be random.

If you wish to index on a different field, simply change the reference to "first" to your desired field name. As with all commands, click on Edit>Fields and then use the syntax below in the Syntax box.
SET SAFETY OFF
ON ERROR com_message=message()
index on ALLT(first) tag mytag
copy to "C:\temp.dbf"
ZAP
APPEND FROM C:\temp.dbf
ALTER TABLE ALIAS() ADD COLUMN record C(4)
REPLACE ALL RECORD WITH PADL(ALLT(STR(RECNO())),4,"0")
index on ALLT(zip) tag myzip
copy to C:\temp.dbf
ZAP
APPEND FROM C:\temp.dbf
DELETE C:\temp.dbf

« Back to Commands

AccuZIP’s Professional Services Team has been a great resource for helping me launch Informed Delivery campaigns for my clients. I am a small direct mail marketing agency specializing in helping my clients find and retain new customers with direct mail. Informed Delivery is the best thing the post office has come up with in my 30+ years in the business. However, just like everything else with the post office, they don't make it easy. AccuZIP has made doing these digital campaigns very simple. I have analyzed campaign results and found the price per click through to the client's website less than an Adword campaign. I am looking forward to working with AccuZIP and their entire Professional Services Team with more clients and campaigns.
S.R., Raleigh, NC