Click here to Skip to main content
15,903,033 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi all

One of my table entries duplicated . now my table contains same row twice
for eg
code  name   .........

ab    Amritha ........
ab    Amritha ........
ac    Tintu .......
ac    Tintu .......

Problem is My table without primary key . i want a delete query to delete duplicated values finally need table as below

code  name    ......
ad    Amritha ........
ac    Tintu   .........


How to do this??

Thanks in Advance
Amritha
Posted
Updated 31-Aug-13 18:02pm
v4
Comments
Sergey Alexandrovich Kryukov 1-Sep-13 0:27am    
Why not keeping records unique in first place? Then you would not need to remove duplicates.
Think about it: are you going to have your database inconsistent for a while, before you remove those duplicates?
—SA
amritha444 1-Sep-13 0:38am    
thnks Sergey Alexandrovich Kryukov for the response
i knw importance of keeping unique row .this is existing live db cant make such changes now. through front value never duplicate.problem is that i exported table twice . im searching for a delete query to do this.
RedDk 1-Sep-13 14:00pm    
Perhaps achieving an appropriate end might be done by simple CREATE TABLE using [Idx][int]IDENTITY(1,1) plus all "old" fields using the "old" data, along with it's duplicates, and SELECT DISTINCT at an xfer query?

1 solution

Hi,
Check this links.This will solve your question

SQL
SQL> DELETE FROM table_name A WHERE ROWID > (
     SELECT min(rowid) FROM table_name B
     WHERE A.key_values = B.key_values);


http://www.orafaq.com/faq/how_does_one_eliminate_duplicates_rows_from_a_table[^]

Remove Duplicate Rows from a Table in SQL Server[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900