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

what is a default tcp/ip socket assigned for sql server? : Sql server database administration

757


what is hash nonclustered index

712


How does a profiler work?

664


What is the xml datatype?

807


Does sql server use java?

729






Define cursor locking

744


What are cursors in ms sql server?

789


Can we store videos inside the sql server table?

711


Define full outer join?

702


what protocol both networks use? : Sql server database administration

717


What is a recursive stored procedure in sql server?

774


How do triggers work?

692


Explain partitioned view?

811


Will count(column) include columns with null values in its count?

842


What are different types of table joins?

754