473,379 Members | 1,174 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Merge two exact tables

I have two tables with the same structure and data.
I want to merge this. I use the next query:

insert into CUSTOMER_A
select *
from CUSTOMER_A_TEMP

He gave an error with the primary key. The are the same.
How can I make it happen that these will be differend?

Pieter
Jun 6 '07 #1
6 2141
Vidhura
99
Merge this into a seperate table or the one of the two tables?
Jun 6 '07 #2
Motoma
3,237 Expert 2GB
I have two tables with the same structure and data.
I want to merge this. I use the next query:

insert into CUSTOMER_A
select *
from CUSTOMER_A_TEMP

He gave an error with the primary key. The are the same.
How can I make it happen that these will be differend?

Pieter
You will not be able to insert your primary key.

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO CUSTOMER_A (Row2, Row3, Row4...all rows except the PK)
  2. (SELECT Row2, Row3, Row4...the same rows as above FROM CUSTOMER_A_TEMP)
  3.  
Jun 6 '07 #3
siva538
44
You will not be able to insert your primary key.

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO CUSTOMER_A (Row2, Row3, Row4...all rows except the PK)
  2. (SELECT Row2, Row3, Row4...the same rows as above FROM CUSTOMER_A_TEMP)
  3.  
This will work only if the pk column is identity in customer_A table.
Jun 7 '07 #4
Motoma
3,237 Expert 2GB
This will work only if the pk column is identity in customer_A table.
Good eye, you are correct with that statement.
Jun 7 '07 #5
nomad
664 Expert 512MB
This will work only if the pk column is identity in customer_A table.
but they should be able to add a new field (ie PK) once the new table is set and go from there if the db is not to big.
Jun 8 '07 #6
siva538
44
but they should be able to add a new field (ie PK) once the new table is set and go from there if the db is not to big.
I dont' think a new table is required in this situation. If the following steps are used sql is smart enough to take care of temp table creation during altering with identity
1. Make sure that destination table has a primary key (automatically uniqueness is taken care)
2. update destination table with the data from customer_a_temp where key matches (if any records exist with this kind)
3. Alter this column (if not) to identity for ensuring future data from customer_temp
4. finally use the above insert stmt for transferring data where keys does not exists

let me know if you have still have any questions.

Thanks,
Sivakumar.
Jun 9 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Nils | last post by:
Hello, my problem: I merged about 1.000 Tables with Create table name (variables) type=merge union=(table1,table2,...,table1000); MySQL now creates a tables, but I can't open it....
2
by: Bob Hynes | last post by:
Hi All, This code is running in WinNT/Access97. I'm looking for some help with getting this code to do two(2) things better then it does now and I'm not sure how to do it. 1. On the...
3
by: cdelarte | last post by:
I would like to be able to mail merge records from multiple mysql tables using a simple template, preferably via a command line script. MSWord mail merge via ODBC will not work for me as it only...
16
by: UDBDBA | last post by:
Hi All: I need some clarification on a MERGE statement. The database is on V8 FP12 (AIX) 64bit. The source table is tableA. The target is a View "FACT" with UNION ALL because of the 512 Gig...
1
by: Bmack500 | last post by:
I'm using the following subroutine. The two different XML files are identical with the exception of three additional records in the second one. One has 450 records, and the other has 453. After...
5
by: Mark Chambers | last post by:
Hi there, Can anyone explain the following (very) simple scenario. 1) I make an exact copy of my "DataSet" and delete one record from a given table (in the copy) 2) I invoke...
7
by: giladp1 | last post by:
I found Albert Kallal's great "Super easy Word Merge" code in his site at: http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html Thanks Albert so much for sharing this. I am looking...
0
by: Dave.Womer | last post by:
All, I'm having an issue merging datasets. It seems everytime I peform a merge of new data on existing data all of the rows of the existing data are modified even if the new data does not...
1
by: joproulx | last post by:
Hello all, Here is my problem: I am trying to merge 2 datasets but I don't want to overwrite rows that are already modified in my working dataset. Example: I have one Dataset with only one...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.