If you know how to use SQL:
SELECT a.* FROM a
LEFT JOIN b on (a.field1 = b.field1 AND a.field2 = b.field2 AND ....)
WHERE b.field1 IS NULL
Will give you all fields in A that are not in B.
Now do
INSERT INTO b
SELECT a.* FROM a
LEFT JOIN b on (a.field1 = b.field1 AND a.field2 = b.field2 AND ....)
WHERE b.field1 IS NULL
And then do (or don't do depending on your needs).
DELETE b FROM b
LEFT JOIN a ON (a.field1 = b.field1 and a.field2 = b.field2 AND ...)
a.field1 IS NULL
Now table a
and b
will be the same.
Delphi code like this should do the trick, but the exact code depends on your database and the query components used.
procedure TForm1.equalize(A, B: TDataset);
var
tablenameA: string;
tablenameB: string;
MyQuery: TQuery;
begin
tablenameA:= IProviderSupport(A).PSGetTableName;
tablenameB:= IProviderSupport(B).PSGetTableName;
MyQuery:= TQuery.Create(self);
MyQuery.Database:= .....
MyQuery.SQL.Text:= ' INSERT INTO '+tablenameA+' .....
MyQuery.ExecSQL;
end;