Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert records 2

Status
Not open for further replies.

pcwaleed

Programmer
Oct 7, 2014
29
IQ
hello
i have tow tables... name and id
table name have 400 records
table id have 400 id
i would like inset 400 ids in table name
like this
name id
ghghg 15565
gfghfgh 6786
kjggjg 8768
etc...

thank you
 
Randomly? Is this to anonymize data? To have a placeholder ID for any name, that isn't the real personid, userid or employeeid?

You could easily [tt]SELECT Name, Cast(0 as integer) as id from employees INTO CURSOR crsRandomized READWRITE[/tt] then populate id with random numbers. As you showed IDs are not even necessarily 1-400, but even higher, you could use something like RAND()*10000. Use a candidate index to enforce any ID to be unique, if an UPDATE triggers an index error simply repeat it, creating another random number.

Bye, Olaf.
 
PcWaleed,

Try this:

create a table tblNames
first field you name ID for type you select Integer (Autoinc)
second field you name cName for type you select character 20
save this file
now in your command window you type: ( <Enter> after each line )
use tblName
append blank
replace cName with "PcWaleed"
append blank
replace cName with "Pcwaleed nmbr 2"
append blank
replace cName with "PcWaleed nmbr 3"
browse normal
and you will see that ID field is filled with 1,2,3
this is due to Integer (Autoinc)
No hazzle with your other table ID and please note the number of ID is irrelevant, it only should be distinct/unique it does not serve as a sequence indicator its only purpose is to identify your record, mind even if you change the sequence of your table into a new table the ID will remain whereas the recno() will change!
Refrain from using recno() as an identifier other than the present record number, which is usefully in present situation but may be part of a bug in an other situation.

Regards,
Koen
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top