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 / shankaranarayanan v
while exists(select count(*) from employee group by empname having count(*)>1)
begin
delete top(1) from employee where empname in
(
select min(empname) as deletedname
from employee
group by empname
having count(*)>1
)
end
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
How to write a query with a right outer join in ms sql server?
Can a table be moved to different filegroup?
What is user-defined scalar function?
What are “lost updates”?
List out what other servers you can use with ssrs?
What are diverse clauses that form a part of sql?
last function used in MS Access to convert sql what function will use in sql
How to create an identity column?
What is a trigger and its types?
How do I debug a stored procedure in sql server?
What does <> symbol mean?
Explain different types of locks in sql server.
How real and float literal values are rounded?
What is filtered index?
What are the purposes of floor and sign functions?