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 / honey

with myCTE as(
select row_number() over( partition by empname order by
empname) as myCount from Employee
)delete from myCTE where myCount >1

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

explain different types of backups avaialabe in sql server? Given a particular scenario, how would you go about choosing a backup plan? : Sql server database administration

589


What is the New in SQL server 2008?

577


What are the different types of Indexes available in SQL Server?

519


why would you call update statistics? : Sql server database administration

575


What is system stored procedures?

583






how you can deploy an ssrs report?

127


What are the types of normalization?

550


What are truncate options available in sql server? : sql server database administration

581


How to count rows with the count(*) function in ms sql server?

536


List down some advantages of sql stored procedure?

557


What is updatable resultset?

516


what are the different types of replication you can set up in sql server? : Sql server database administration

514


Ms sql server index?

536


What is nested transaction?

536


How many ways to create table-valued functions?

584