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
What is a derived table?
What are click through reports?
What is the difference RDBMS and Graph Database?
What is the rdl file?
What are “lock” hints?
explain the storage models of olap? : Sql server database administration
Explain microsoft sql server functions?
What is openxml in sql server?
What is difference between temp table and cte?
What is 2nf normalization?
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?
How to attach adventureworkslt physical files to the server?
What is the full form of dql?
Describe the functionalities that views support.
Explain what is lock escalation and what is its purpose?