adspace
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
Does view occupy space?
If any stored procedure is encrypted, then can we see its definition in activity monitor?
How do I find query history in sql server?
What are the different types of subquery?
What is self contained sub query?
What is an indexed view?
do you know how to configure db2 side of the application? : Sql server database administration
what is the difference between openrowset and openquery?
What is in place upgrade in sql server?
Explain “row_number()” in sql server with an example?
What is sql or structured query language?
what is spatial nonclustered index
What are the source of constraints?
What is normalization and what are the advantages of it?
You have a stored procedure, which execute a lengthy batch job. This stored procedure is called from a trigger you do not want to slow the data entry process you do not want trigger to wait for this batch job to finish before it completes itself what you can do to speed up the process?