How to retrieve duplicate rows in a table?
How to delete the duplicate entries in a table?

Answer Posted / nagabhushan adhikari

These are duplicates....

select distinct(col1),col2,col3.... into #temp from table
group by col1 having count(1) > 1

by the below delete duplicates
delete table from table A, #temp B where A.col1= B.col1

by this insert only a single record
insert into table select col1, col2,col3... from #temp

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what are the different stages of Report Processing?

97


What is scheduled job and how to create it?

556


What is meant by referential integrity?

593


What is the use of commit?

546


Can you please explain the difference between primary keys and foreign keys?

660






What is the purpose of floor function?

543


What is the difference between an index and a unique index?

548


What is snapshot report?

129


Sql server reporting services vs. Crystal reports.

96


What is difference between group by and having?

566


Explain full-text indexing?

518


What is SubQuery in SQL Server 2008

558


What is primary key and example?

507


What are subqueries in sql server?

601


What is SQL Azure Federations?

98