Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Differences in large amounts of data
Message
De
08/12/2006 22:30:41
Mike Yearwood
Toronto, Ontario, Canada
 
 
À
08/12/2006 19:17:38
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Maintenance bases de données
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01176309
Message ID:
01176335
Vues:
9
>Given a large database, and a complete new set of data that may have many duplicates with the existing set of data, what would be the most efficient way to find the differences (items no loger there, items new, and items modified)??

Well, I've had good results with using 2 sql commands provided there is a common ID between the two files.

select * from table1 tgt ;
inner join table2 src on tgt.id = src.id ;
where ;
src.field1 # tgt.field1 ;
or src.field2 # tgt.field2 ;
into cursor c_Modifications

Repeat as many fields as you have. I think the first field that is different stops the processing of the remaining OR conditions.

select * from table2 src ;
where src.id not in (select id from table1) ;
into cursor c_Additions

A third query could give the records that are no longer in the new set of data.

select * from table1 src ;
where src.id not in (select id from table2) ;
into cursor c_Removed

HTH
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform