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 'Join' and explain its various types.
What are logical/boolean operations in ms sql server?
What is a deadlock and what is a live lock?
What is mean by clustered index and non clustered index, give syntax of creation? : sql server database administration
What is the difference function and stored procedure?
How do I create a partition table in sql server?
Can we use max in where clause?
What are the security related catalog views? : sql server security
Do you know what are the properties of the relational tables?
Which tcl commands are available on the sql server?
What is the order in which the sql query is executed?
What is difference between temp table and cte?
you added a row to a view, but the row is not shown on the view. Explain how this can happen, and how you can remedy the situation
What are the export options of ssrs?
What is self contained sub query?