Answers
Jul 16, 2010 - 07:02 AM
Use this to get the correct data fill in from table A to table B.
this takes care of the exsisting but incorrect records by updating those rows with values from table A and the non-exsisting records in table B by inserting those rows from table A.
MERGE INTO B
USING A
ON (B.id = A.id)
WHEN MATCHED THEN
UPDATE
SET B_col1 = A_col1,
B_col2 = A_col2,
B_col3 = A_col3,
B_col4 = A_col4
WHEN NOT MATCHED THEN
INSERT (B_col1,B_col2,B_col3,B_col4)
VALUES (A_col1,A_col2,A_col3,A_col4);
Hope this helps.
Mar 09, 2011 - 09:27 PM
If you are sure that ,the two tables must contain same data ,then you can truncate the wrong data table and insert the data to it from the correct table by
Tuncate table
insert into table
B,
If you simply want to insert the data,which is not in wrong table
you can use the sql provided by Suleman
Add New Comment