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 the size of transaction log file?
What is RMS migrations?
How do database indexes work?
What is the sql case statement used for? Explain with an example?
What is field with example?
How many types of attribute relationships are there? : sql server analysis services, ssas
How to identify current user in ssrs report?
Why do we backup Active Directory ?
How to create an identity column?
What is the xml datatype?
What functions can a view be used to performed?
What does truncate do?
What is difference between delete & truncate commands?
Give the query of getting last two records from the table in SQL SERVER?
what is a transaction? : Sql server database administration