• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 163
  • Last Modified:

Compare 2 Table

How can I compare an old table with a new table in order to filter out the new records added to the new table.

Thanks.
0
choonfong
Asked:
choonfong
  • 2
1 Solution
 
deightonCommented:
Open both tables,
read new table a record a time.
do a oldtable.FindFirst on the old table looking for records matching those in new table.

if oldtable.nomatch = true then record is new

0
 
caraf_gCommented:
Hi choonfong,

A very similar question has been asked in http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=10330744 
See my comments there.

You can use a similar technique on recordsets, provided they're ordered.
0
 
caraf_gCommented:
Just in case you don't know, you can get an ordered recordset quite easily by using an sql statement such as

"SELECT * FROM YOURTABLE WHERE SOMECONDITION ORDER BY UNIQUEFIELDS"

Make sure the order criteria make up a unique key otherwise you'll have trouble finding out whether two records with identical criteria are in fact the same record ;-)
0
 
brice123Commented:
You could use a simple SQL statement.
For example (in MS-SQL 7) :

select
      t1.SectorID,
      t1.Description
from
      Sectors t1
left outer join
      NewSectors t2
on       t1.SectorID = t2.SectorID
where      
      t2.Description is Null
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now