Search code examples
visual-foxprofoxpro

FoxPro My using .prg(coding) move fields


I would like toalter the table to move fields from one place to another.

ABS1
ABS2
ABS4
ABS8
ABS3

So I would like to move ABS3 after ABS2, but not move the physicly. Would like the code do it for me.


Solution

  • Assuming that table is named "mytable.dbf" and you have exclusive access:

    select * from mytable into table tmp
    use in ('myTable')
    erase ('myTable.dbf')
    *    erase ('myTable.fpt')
    *    erase ('myTable.cdx')
    select ABS1, ABS2, ABS3, ABS4, ABS8 from tmp into table myTable
    

    and then recreate the indexes as well.