If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Help with SQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-16-10, 10:55
itsonlyme44 itsonlyme44 is offline
Registered User
 
Join Date: Dec 2007
Posts: 261
Help with SQL

Running DB2 on Windows V9.5

Have two identical tables in different schemas with different row counts and duplicates.

I need to insert from one table into another and replace duplicates???
Reply With Quote
  #2 (permalink)  
Old 07-16-10, 11:18
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
You should be able to do it with the MERGE statement.
Reply With Quote
  #3 (permalink)  
Old 07-16-10, 12:25
Lenny77 Lenny77 is offline
Registered User
 
Join Date: Jul 2009
Location: NY
Posts: 886
Wink Without MERGE

In some DB2 versions MERGE doesn't exist:

Code:
Insert     into  table2  t2
select  * from table1  t1
where 
not exists (select 1 from table2 t3 where t3.clm1 = t1.clm1)
Lenny
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On