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)

Answers were Sorted based on User's Feedback



How to delete duplicate records from a table?(for suppose in a table we have 1000 Records in that w..

Answer / sneha

select distinct * from table into new_table;

delete table;

select * from new_table into table;

Is This Answer Correct ?    8 Yes 6 No

How to delete duplicate records from a table?(for suppose in a table we have 1000 Records in that w..

Answer / cp

DELETE FROM emp WHERE ROWID NOT IN(SELECT MAX(ROWID) FROM
emp GROUP BY empno)

Is This Answer Correct ?    2 Yes 3 No

How to delete duplicate records from a table?(for suppose in a table we have 1000 Records in that w..

Answer / smitha

;with empctc(empid,ename,sal,deptid,ranking)
as
(Select empid,ename,sal,deptid,ranking=Dense_rank() over (
partition by empid,ename,sal,deptid order by NEWID() asc)
from emp
)
delete * from empctc where ranking>1

Is This Answer Correct ?    2 Yes 5 No

How to delete duplicate records from a table?(for suppose in a table we have 1000 Records in that w..

Answer / sirisha

with numbered as(select rowno = row_number() over(partition
by empid order by empid),empname from employee)delete from
numbered where rowno > 1

Is This Answer Correct ?    1 Yes 6 No

How to delete duplicate records from a table?(for suppose in a table we have 1000 Records in that w..

Answer / 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

More SQL Server Interview Questions

How to download microsoft sql server 2005 express edition?

0 Answers  


Do you know the different ddl commands in sql?

0 Answers  


Do you think BCNF is better than 2NF & 3NF? Why?

0 Answers   Ernst Young,


What is an identity column in insert statements?

0 Answers  


Table - Products has number of products as below Productid ProductName 1 iPhone 2 iPad 3 BlackBerry Table - SalesPersonProduct has the below records Salespersonid productid S1 1 S1 2 S1 3 S2 1 S3 2 Write a SQL query that returns the number of sales for each product

2 Answers  






Can sql server be linked with other servers like oracle?

0 Answers  


What number sorts of privileges are accessible in sql?

0 Answers  


What is partitioned view?

0 Answers  


How to drop an existing table with "drop table" statements in ms sql server?

0 Answers  


How network traffic be reduced by using the stored procedure?

0 Answers   Accenture,


Explain index in sql server?

0 Answers  


How do I change my passwords (database, LDAP, and so on) without causing an outage?

0 Answers   IBM,


Categories