Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Overwrite duplicate records from one table to another

Status
Not open for further replies.

naitx

Programmer
Apr 18, 2008
10
PH
hi,

I'm trying to Transfer all records from table A to table B and I would like to overwrite duplicate records from table B.

this code only transfer the record but not overwrite duplicate records.

Code:
cn.Execute "INSERT INTO B SELECT * FROM A'"


can someone show me how to do this?


Thanks in Advance
 

You can try:
Code:
    [green]'PK is a Primary Key[/green]
Cn.Execute "DELETE from B WHERE B.PK IN " _
    & "(SELECT B.PK FROM A, B WHERE B.PK = A.PK) "
    [green]'We don't have any duplicates any more[/green]
Cn.Execute "INSERT INTO B SELECT * FROM A"


Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top