SELECT *, myNewField1 AS AltName, myNewField2 AS Amount2 ;
FROM oldTable INTO DBF NewTable
INDEX ON .... whatever..
CLOSE DATABASE
Now that the NeTable is available..
DELETE FILE "oldTable.dbf"
DELETE FILE "oldTable.CDX"
DELETE FILE "oldTable.FPT"
If required.. REname NewTable to the same name as old table.
Method2
*********
USE oldTable
COPT STRU EXTENDED TO temp
USE temp
APPEND BLANK
REPLACE fieldname etc etc...
and now use the temp to create the NewTable .
Look in the help file on COPY TO STRU EXTE
* -- Collect Field info from SourceTable into Array
USE SrcTable EXCLUSIVE
SELECT SrcTable
=AFIELDS(SrcFldArr) && SrcFldArr is array
USE && close SrcTable
* -- Add array elements for new fields ---
m.nArrRows = ALEN(SrcFldArr,1)
DIMENSION SrcFldArr (m.nArrRows + 1,4) && to add 1 field
SrcFldArr(m.nArrRows+1,1) = "NEWFLD" && new field name
SrcFldArr(m.nArrRows+1,2) = "N" && new field type
SrcFldArr(m.nArrRows+1,3) = 8 && new field integ size
SrcFldArr(m.nArrRows+1,4) = 3 && new field decimal size
* -- Create new table structure
CREATE TABLE tmptable FROM ARRAY SrcFldArr
SELECT tmptable
* -- Read in records from SrcTable
APPEND FROM SrcTable
* -- Move new structure & records into SrcTable
COPY TO SrcTable
USE && close TmpTable
ERASE TmpTable && clean house
Method 2:
Use SELECT - SQL
SELECT SrcTable.*,;
SPACE(10) AS newfld1,;
99999 AS newfld2;
FROM SrcTable;
INTO TABLE TmpTable
SELECT SrcTable
USE && close SrcTable
* --- Copy new structure and records into SrcTable
SELECT TmpTable
COPY TO SrcTable
ERASE TmpTable
NOTE: You will need EXCLUSIVE access to the table that you are wishing to change since the COPY TO ... command will not work if the table is in USE.
Good Luck,
JRB-Bldr
VisionQuest Consulting
Business Analyst & CIO Consulting Services
CIOServices@yahoo.com
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.