Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Appending or inserting from other table
Message
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Divers
Thread ID:
01347442
Message ID:
01347583
Vues:
10
>I have:
>
>Table1 (large table with over 50,000 records)
>
>table 2 (always a small table with 100 records or less)
>
>I want add data of table 2 to table 1
>
>if field table2.device_id already exists on table1.device_id
>
>= messagebox (Record already exists)
>
>What is the best way to do such append ?

You can select records that already exist into a cursor and insert records that don't exist, e.g.

select table2.device_ID from table 2 inner join table1 on table2.device_id = table1.device_id into cursor curExistingRecords

Process this cursor to show your messagebox

insert into table1 select * from table2 left join curExistingRecords cur on table2.device_id = cur.device_id where cur.device_id IS NULL && to insert only new records
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform