* No guarantees but...
USE Table1 NOUPDATE
USE Table2 IN 0
IF FLOCK("Table2")
SELECT * FROM Table1 T1, Table2 T2 ;
WHERE T1.A = T2.A AND T1.B = T2.B ;
AND T1.C = T2.C AND NOT T1.D = T2.D2 ;
AND NOT T1.E = T2.E ;
INTO CURSOR UpdateThese
* You could Delete and append or...
SET ORDER TO ABC IN Table2
SET RELATION TO A+B+C INTO Table2
* We're only scanning through the records that
* are common to both tables and have differences.
SCAN
REPLACE Table2.D WITH UPdateThese.D ;
Table2.E WITH UPdateThese.E IN Table2
ENDSCAN
* Select all the records that aren't in table 1.
SELECT * FROM Table1 ;
WHERE A + B + C NOT IN (SELECT A + B + C FROM Table2) ;
INTO CURSOR AppendThese
* These are all the records that should be appended.
SELECT Table2
APPEND FROM (DBF("AppendThese"))
ENDIF>I am trying to append or update from 1 table to another. They both have the same structure. I cannot make changes to the source table as it beelongs to another company. The source table has no unique field, however, a combination of 3 fields is unique. So I set an index in the target table consisting of these 3 fields. I must evaluate each record in the source table, if it does not exist in the target table I append it. If it does exist, I must see if it has been updated and if so, update the appropriate fields. This is working o.k. but it is very slow as the target table continues to grow and my do while not eof() and seek commands seem to be the only way to make my updates. Any suggestions would be appreciated.
>
>for example the 2 tables have fields A - E.
>None are unique but A + B + C is unique
>
>use table 1
>do while not eof()
> store A + B + C to memvar
> use table 2
> seek A + B + C
> if found()
> if fields D + E dont match
> update
> endif
> else
> append record from table1
> endif
> skip
>enddoCharlie