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!

Append from having different field names

Status
Not open for further replies.

LenaS

Technical User
Nov 28, 2000
98
US
I want to Append to a file but my fields are named differently. How can I accomplish this?
 
If the fields in the table you want to append to are in the same order as the fields in the table youwant to append from, (If not you can always rearrange them), you can use:

Code:
USE TableFrom
COPY TO Temp.TXT SDF

USE TableTo
APPEND FROM Temp.TXT SDF

Otherwise, you will have to run through the first table and add them to the other table:

USE TableFrom IN 0
USE TableTo   IN 0
SELECT TableFrom
SCAN
   SELECT TableTo
   APPEND BLANK
   REPLACE TableTo.Field1 WITH TableFrom.Field1
   REPLACE TableTo.Field2 WITH TableFrom.Field2
   .
   .
   .
   SELECT TableFrom
ENDSCAN
Dave S.
 
If they are not in the same order, you may want to run a query and rename the fields there then append from that cursor to the table you want them in

select filed1 as custname, field2 as custadd from cust1 into cursor tempcust
select cust2
append from cust1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top