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
how to trace the traffic hitting a sql server? : Sql server database administration
What is the difference between indexing and hashing?
Do you know what is fill factor and pad index?
What is a dbms wizard?
What is the difference between sdf and mdf?
How to get a list of columns in a view using "sys.columns" in ms sql server?
explain how to create a new schema in a database? : Sql server database administration
What is the difference between substr and charindex in the sql server?
What's new in sql management studio for sql server? : sql server management studio
What are the types of dml?
What are xml indexes?
Explain the difference between clustered and non-clustered index?
Explain the collation?
Explain the usage of floor function in sql server.
what is the difference between count(*) and count(1) ?