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
Define union, union all, minus, intersect?
How to loop through the result set with @@fetch_status?
What is the difference between push and pull subscription? : sql server replication
What is cached report?
Can binary strings be used in arithmetical operations?
What are the tool windows in sql server management studio? : sql server management studio
How to return the date part only from a sql server datetime datatype?
What happens if you add a new index to large table?
What is the main difference between ‘between’ and ‘in’ condition operators?
How can I track the changes or identify the latest insert-update-delete from a table?
What is a non-clustered index?
Write an sql query to find first weekday of the month?
I applied Transactional with updatable subscriptions replication on 2 tables now i want to delete those 2 tables but i cannot delete those tables as replication is running how can i stop replication for those 2 tables(but i don't want to delete those replicated tables but i need to stop the replication) how can i do that
How to modify an existing user defined function?
How to create user messages with print statements in ms sql server?