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 / samba shiva reddy . m
delclare @temp(empname varchar(50),sal int)
select * into @temp
FROM employee
GROUP BY empname, salary
HAVING count(*) > 1
delete from employee
select * into employee from @temp as temp
| Is This Answer Correct ? | 0 Yes | 1 No |
Post New Answer View All Answers
Tell me what is difference between view and materialized view?
What is “asynchronous” communication in sql server service broker?
What are the tool windows in sql server management studio? : sql server management studio
How do you trace the traffic hitting a sql server?
How to get a list all databases on the sql server?
What is role playing dimension with two examples? : sql server analysis services, ssas
What is the purpose of self join?
What is replace and stuff function in sql server?
How many types of dimensions are there and what are they? : sql server analysis services, ssas
How to create a store procedure with encryption?
What is policy management?
Explain timestamp datatype?
What are the limitations in ssrs on sql server express edition?
What are the different types of columns types constraints in the sql server?
Explain the disadvantages of cursors?