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...
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.
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.