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
What is sub-query in sql server?
How to find index size for each index on table?
How to use go command in "sqlcmd"?
What are functions in the sql server?
Do you know hot add cpu in sql server 2008?
Does server sql treat char as a variable-length or fixed-length column?
Describe how to use linked server?
You want to check the syntax of a complicated update sql statement without executing it. What command should you use?
What are the advantages of paper records?
What are the system database in sql server 2008?
What are the aggregate and scalar functions?
Where do we use trace frag?
What is instead of trigger sql server?
Where are full-text indexes stored?
How can I add Reporting Services reports to my application?