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
Define compound operators?
What is the library index called?
In which tcp/ip port does sql server run? Can it be changed?
what is datawarehouse?
what are the core components of SSRS?
What are “phantom rows”?
Call by value and call by reference in procedure and function, with NOCOPY.
What guidelines should be followed to help minimize deadlocks?
What samples and sample databases are provided by microsoft?
What is difference between getdate and sysdatetime in sql server 2008?
What do you understand by physical_only option in dbcc checkdb?
What are dml (data manipulation language) statements in ms sql server?
can an order by clause be used in a creation of a view?
How to create a trigger for insert only?
Explain what is row_number function?