Delete duplicate rows from a table without primary key by
using a single query
Table Employee
empname salary
A 200
B 300
A 200
C 400
D 500
D 500

Output should be

A 200
B 300
C 400
D 500

Answer Posted / sumathy

Execute the following query for each duplicate value.

1.Delete duplicate of empname='A'

delete top(select count(*)-1 from employee where
empname='A') from employee where empname='A'

2.Delete duplicate of empname='D'

delete top(select count(*)-1 from employee where
empname='D') from employee where empname='D'

Is This Answer Correct ?    9 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is a derived table?

509


What are click through reports?

99


What is the difference RDBMS and Graph Database?

629


What is the rdl file?

88


What are “lock” hints?

588






explain the storage models of olap? : Sql server database administration

521


Explain microsoft sql server functions?

540


What is openxml in sql server?

616


What is difference between temp table and cte?

533


What is 2nf normalization?

539


How many clustered indexes can be created on a table? I create a separate index on each column of a table. what are the advantages and disadvantages of this approach?

678


How to attach adventureworkslt physical files to the server?

629


What is the full form of dql?

512


Describe the functionalities that views support.

660


Explain what is lock escalation and what is its purpose?

511