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
What does the update command do?
Your company has 50 branches all over the country all the branches, including the head office have sql server as the database every night all 50 branches upload certain information to the head office which replication topology is best suited for the above scenario?
What is multi-statement table-value user-defined function?
Is there any difference between primary key and unique with the not null condition?
Can we store videos inside the sql server table?
What is a select query statement in ms sql server?
What is transact-sql ddl trigger?
List the types of recovery model available in sql server?
explain declarative management framework (dmf) in sql server 2008?
What is a transaction and why is it important?
Define compound operators?
Data table as parameter in sql server?
What are actions, how many types of actions are there, explain with example? : sql server analysis services, ssas
What is checkpoint process in the sql server?
What is an example of a foreign key?