How to delete duplicate records from a table?(for suppose in
a table we have 1000 Records in that we have 200 duplicate
Records , so ,how to findout that duplicate Records , how to
delete those Records and arranged into sequence order? one
more thing that there is no primary key at all)

Answer Posted / pooja narang

We will get the duplicate records and insert them into a
new temp table by using below query:

select * into tmp_Employee
from Employee
having count(distinct *) > 1

Now delete the duplicate records from Employee table:

delete from Employee
having count(distinct *) > 1

Now insert the records from tmp_Employee to Employee table:

insert into Employee
select * from tmp_employee

drop table tmp_employee

Is This Answer Correct ?    4 Yes 15 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

how to avoid cursors? : Sql server database administration

491


What command do we use to rename a database?

609


Does the order of columns in update statements matter?

474


What do you mean by recursive stored procedure?

504


Is port 1433 secure?

533






Can group functions be mixed with non-group selection fields in ms sql server?

535


What is data block and how to define data block size?

595


How to skip remaining statements in a loop block using continue statements?

538


What are the types of sql server?

515


How many primary keys are possible in a table?

515


What is ms sql server reporting services?

504


Why would you use sql agent?

727


Explain logical operators in sql server?

564


what do you understand by change data capture?

552


How to add the custom code in Report?

97