Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to add a column at a particular position?
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01018285
Message ID:
01018342
Views:
15
David, Here a simple way. Again not tested. I don't know how long INSERT (old command not INSERT - SQL) will be supported.
USE YourTable
COPY STRUCTURE EXTENDED TO strYourTable
USE strYourTable EXCLUSIVE
GOTO 3 && Go to position where you want to insert the field
INSERT BLANK
REPLACE Field_Name WITH "FieldName",;
        Field_Type WITH "C",;
        Field_Len  WITH 10,;
        ..... && All neccessary fields 
CLOSE DATABASES ALL
CREATE Temptable FROM strYourTable
USE TempTable
APPEND FROM YourTable
*** DO ALL INDEX ON Here
CLOSE DATA ALL
ERASE YourTable.*
RENAME TempTable.DBF TO YourTable.DBF
RENAME TempTable.FPT TO YourTable.FPT && If you have a Memo/GENERAL/BLOB fields
RENAME TempTable.CDX TO YourTable.CDX
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform