Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Appending or inserting from other table
Message
From
14/09/2008 15:45:33
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
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:
01347446
Views:
14
>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 ?

I would first, separately, check for duplicate data.
select device_id from Table2;
  where device_id in (select device_id from Table1);
  to screen noconsole
if _tally > 0
...
* or:
select *;
  from table1 join table2 on table1.device_id = table2.device_id;
  to screen noconsole
if _tally > 0
...
Then, if there is no error, just do an APPEND FROM.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform