IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to delete the duplicate records in a table


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sundar_svb

New User


Joined: 16 Oct 2005
Posts: 1

PostPosted: Wed Oct 19, 2005 11:57 pm
Reply with quote

hi ..
how to delete duplicate records in a table.....


By,
Sundar
Back to top
View user's profile Send private message
sairam

New User


Joined: 30 Aug 2005
Posts: 58
Location: Kolkata

PostPosted: Thu Oct 20, 2005 10:08 am
Reply with quote

Hi Sundar

I think it is not possible to delete duplicate records keeping one from the table with no primary key.
So to add an primary key (ex. id) then follow this query

Delete from Test s where id <
(Select Max(id) from Test t where s.a = t.a and
s.b = t.b and
s.c = t.c)


or you can transfer the one distinct record to another table and delete all in original table and then transfer the distinct one back.

Try this one (i am not sure)
for transferring distinct record to a table which is not exist

select distinct * into <NewTable> from <MyTable>
Back to top
View user's profile Send private message
paulstephen

New User


Joined: 20 Oct 2005
Posts: 20
Location: Chennai

PostPosted: Thu Oct 20, 2005 4:33 pm
Reply with quote

If its a one time requirment u can also use file aid for DB2.
If its on a routine basis plz use a cursor with for delete of option in ur application program
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts DELETE SPUFI DB2 1
No new posts Load new table with Old unload - DB2 DB2 6
No new posts Duplicate transid's declared using CEDA CICS 3
Search our Forums:

Back to Top