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 / devender kumar
This query is for sql server 2005 and higher version of sql
server. It will not run on older versions.
with myCTE as(
select row_number() over( partition by empname order by
empname) as myCount from Employee
)delete from myCTE where myCount >3
| Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
How do I install sql server?
What are the advantages of having an index on the sql server?
What are key constraints?
What is a group function explain with an example?
What are the steps to process a single select statement?
Are there any preferred steps that need to be taken care of before starting the installation of sql server 2000?
How to retrieve field values using mssql_result()?
How to use “drop” keyword in sql server and give an example?
Explain about merge replications?
What is raid, and how it can influence database performance?
What is database white box testing?
What is a linked server in sql server?
What is the current limitation of the size of SQL Azure DB?
What is blocking?
How to get a list of columns in a view using the "sp_help" stored procedure?