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

Answers were Sorted based on User's Feedback



Delete duplicate rows from a table without primary key by using a single query Table Employee em..

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

Delete duplicate rows from a table without primary key by using a single query Table Employee em..

Answer / v.krishnakumar

using the keyword distinct we can avoid the duplicate value
in our table,(ex) SELECT DISTINCT empname FROM Employee

Is This Answer Correct ?    0 Yes 1 No

Delete duplicate rows from a table without primary key by using a single query Table Employee em..

Answer / arijit mandal

DELETE FROM Employee a
WHERE ROW_NUMBER() <>
( SELECT MIN( ROW_NUMBER() )
FROM Employee b
WHERE a.empname = b.empname
AND a.salary = b.salary)

Is This Answer Correct ?    0 Yes 2 No

Delete duplicate rows from a table without primary key by using a single query Table Employee em..

Answer / jansi rani

SELECT EMPNAME,SAL FROM EMP GROUP BY EMPNAME,SAL

Is This Answer Correct ?    0 Yes 4 No

Post New Answer

More SQL Server Interview Questions

What is buffer cash in sql server?

0 Answers  


What happens when transaction log is full?

0 Answers  


Can you explain what is sql server english query?

0 Answers  


How to enter comments in transact-sql statements?

0 Answers  


What is the difference between 2-Tier architecture and 3-Tier architecture

15 Answers   CTS, MCN Solutions, Oracle,






Can we add a cpu to sql server?

0 Answers  


Why use triggers?

0 Answers  


What stored by the model? : sql server database administration

0 Answers  


What is the difference between a check constraint and a rule?

0 Answers  


What is normalization of database?

0 Answers  


Other than truncate statement, which other command can by-pass the trigger on the tables?

0 Answers  


What is user defined stored procedures?

0 Answers  


Categories