Link to home
Start Free TrialLog in
Avatar of hkgal
hkgal

asked on

how can I compare two databases in foxpro to check if they are identical?

I have two databases in foxpro and want to check if the records inside are all identical including data type.
are there any means I can do so?
Avatar of jrbbldr
jrbbldr

There would be 3 possible things necessary to check for IDENTICAL
  1. Field Names
  2. Field Parameters - Type, Size
  3. Field Contents

The first 2 are easy using the AFIELDS() function.
You can create an array on each of the 2 tables describing the field info and then run a comparison of the 2 field info array values.

The 3rd item is more involved since you would need to scan each record and then, within that record, compare each field value against the other table's matching record's field value.

The last thing to check, not listed above, would be Indicies on each table.
You can do that using the TAG() and KEY() functions

Good Luck

Avatar of hkgal

ASKER

sorry i am new to foxpro, don't really know how to work it out...

for e.g., the table structure as:
ID        Name       Sales
01       KL             `100
23       Peter           200
Avatar of Olaf Doschke
It's not really that simple, but if you're asking about structure AND data in dbfs, then the files must be identical, eg a simplistic check would be:

FILETOSTR('c:\data\db1\table.dbf')==FILETOSTR('c:\data\db2\table.dbf')

If the order of data can be different and there can be a difference in deleted records existing in one dbf and not the other, then it's harder to determine.

Bye, Olaf.
You can compare structure using AFIELDS, but if dbfs are part of a dbc each you can also simply compare data within each dbc file, as a dbc file (together witch dcx and dct file) is nothing more or less than a free dbf with data about it's tables and more.

Bye, Olaf.
The easiest way to check everything at once is to do the following:

1) Copy both tables to SDF format. It will depend on field width and contents
USE table1
COPY TO file1.sdf TYPE SDF
USE table2
COPY TO file2.sdf TYPE SDF

2) Use DOS comment FC to compare for both files
FC file1.sdf file2.sdf
ASKER CERTIFIED SOLUTION
Avatar of jrbbldr
jrbbldr

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hkgal

ASKER

excellent! Thanks!