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 / b.v.rajaram

delete top (select count(*)-(select count(distinct empname )
from Employee) from Employee)from Employee
where a in (select distinct a from Employee)

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How you can minimize the deadlock situation?

748


What is sql server management studio? : sql server management studio

757


What is filtered index?

831


What stored procedure would you use to view lock information?

742


Mention the differences between substr and charindex in sql server.

717


What is recursion? Is it possible for a stored procedure to call itself or recursive stored procedure? How many levels of sp nesting are possible?

745


How you trouble shoot when any job fails

1690


what is the difference between openrowset and openquery?

773


How many types of stored procedures are there in sql server?

750


Mention what are the different types of ssrs reports?

128


Explain the use of containers in ssis and also their types?

712


While you are inserting values into a table with the insert into .. Values option, does the order of the columns in the insert statement have to be the same as the order of the columns in the table?

796


How to get a list of columns in a view using the "sp_columns" stored procedure?

809


Can you explain what is indexed view? How to create it?

724


Explain how dts is used to extract, transform and consolidate data?

772