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

What is recursion? Is it possible for a stored procedure to call itself or recursive stored procedure? How many levels of sp nesting are possible?

569


how we use window authentication connection with sql server.?

637


What are the different SQL Server Versions you have worked on?

565


What is transact-sql language?

586


Where are sql server user names and passwords stored in sql server?

549






Why use view instead of a table?

541


How to execute stored procedure in select statement sql server?

543


How many types of triggers in sql server?

535


Why it is recommended to avoid referencing a floating point column in the where clause?

548


How data can be copied from one table to another table?

519


What are the purposes of floor and sign functions?

548


What are indexes in ms sql server?

562


what is a join and explain different types of joins? : Sql server database administration

544


Explain activity monitors

631


What is the Difference Between Primary and Foreign Key?

594