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 to find index size for each index on table?
What is normalization 1nf 2nf 3nf?
How to rebuild the master database?
Which tools are available to manage SQL Azure databases and servers?
What do you mean by an execution plan? How would you view it?
What will be the maximum number of index per table?
What is merge replication?
How to turn on the mssql api module in php?
What are different replication agents and what's their purpose? : sql server replication
How to use subqueries in the from clause in ms sql server?
How to get a list of columns in a view using the "sp_columns" stored procedure?
How to configure odbc dsn with different port numbers?
What is nested transaction?
Your company has 50 branches all over the country all the branches, including the head office have sql server as the database every night all 50 branches upload certain information to the head office which replication topology is best suited for the above scenario?
What are the advantages of mirroring?