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 data modification?
You are designing a strategy for synchronizing an SQL Azure database and multiple remote Microsoft SQL Server 2008 databases. The SQL Azure database contains many tables that have circular foreign key relationships?
What is 1nf normalization form?
Explain an automatic checkpoint
How many cores do I need for sql server 2016?
What is a partition function in sql server?
How to encrypt Strored Procedure in SQL SERVER?
What is table-valued sub query?
How to enable tcp/ip protocol on a sql server?
What is the difference between mysql and sql server?
What is sql or structured query language?
Can you explain what is sql server english query?
How to add additional conditions in SQL?
What is named query? : sql server analysis services, ssas
What are sql azure firewall rules?