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

Describe and explain about SQL native client?

621


What Is Rdbms?

673


What is a cursor, index in sql?

576


How do I view a stored procedure in sql server?

519


What are the different types of sql server replication? : sql server replication

624






Define right outer join?

546


How to download and install microsoft .net framework version 2.0?

552


How to automatically create a log when an exception is being received into SQL Server?

738


What are commit and rollback in sql?

567


Are there issues when exporting SSRS reports into Microsoft Excel? When my users are trying to export a SSRS report into Microsoft Excel, one or two columns in the report appear to merge together. Why might this be?

134


What does it mean to normalize a database and why would you do it?

530


Give an example of why you would want to denormalize a database

516


How many levels of sp nesting are possible?

557


What is the purpose of floor function?

541


What do you know about system database? : SQL Server Architecture

494