Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Appending or inserting from other table
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2008 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01347442
Message ID:
01347583
Views:
9
>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
Previous
Reply
Map
View

Click here to load this message in the networking platform