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
Is sql different from sql server?
What are user defined functions in ms sql server?
How to modify an existing user defined function?
When cursors are useful?
How to return the top 5 rows from a select query in ms sql server?
How to start sql server browser service?
What is difference between after and before?
Explain system scalar functions?
Explain the disadvantages of cursors?
Explain transaction server consistency?
Write a SQL command to insert and update only a particular field?
What is shrink log file?
What gets stored inside msdb database?
What is the correct order of the logical query processing phases?
How do you make a trace?