Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to delete the duplicate records in a table

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: How to delete the duplicate records in a table
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm
No new posts Inserting records based on conditions vickey_dw DFSORT/ICETOOL 9 Wed Feb 22, 2017 1:33 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us