Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Compare Tables
Message
From
22/08/2002 07:12:21
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
21/08/2002 19:51:36
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00692106
Message ID:
00692364
Views:
32
>Oops, I left out an important element in the question. I want to compare the DATA to see if the file are identical.
>
>Bill

Now that is a major challenge. You could do a byte-by-byte comparison. Or, especially if your table has a PK, you could run a SELECT statement to see, for instance, what records are in one table but not in the other, or what records have different values in certain fields.

A byte-by-byte comparison is actually quite easy:
? FileToStr("Table1.dbf") = FileToStr("Table2.dbf")
* .T. if identical
Since the tables might have the same data in a different order (especially in the memos!), I would first copy them to temp tables:
use Table1 order "MyPK"
copy to Temp1
use Table2 order "MyPK"
copy to Temp2
use
? "Table1 and Table2 are " + iif(FileToStr("Temp1.dbf") = FileToStr("Temp2.dbf"), "identical", "different")
? "The corresponding memo files are " + iif(FileToStr("Temp1.fpt") = FileToStr("Temp2.fpt"), "identical", "different")
HTH, Hilmar.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform