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 functions can a view be used to performed?
What are the two modes of authentication in sql server?
Write the syntax for stuff function in an sql server?
How to invoke a trigger on demand?
Is t sql the same as sql server?
What is a hint?
You schedule a job to run every minute what will happen if the first job runs more than 1 min? Will the second instance of the job start?
What is the difference between clustered index and primary key?
Define union, union all, minus, intersect?
Where does the copy job runs in the log shipping primary or secondary? : sql server database administration
what is raid? : Sql server database administration
When does a workload on SQL Azure get throttled?
What are the triggers in sql?
Why is normalisation important?
Describe the left outer join & right outer join. : sql server database administration