How to retrieve duplicate rows in a table?
How to delete the duplicate entries in a table?
Answer Posted / madhur/amrutha
select ROW_NUMBER() OVER (ORDER BY names ASC) AS ROWID, *
into #temp from emp
select * from #temp where ROWID not in(
select b.ROWID from
(
select ROW_NUMBER() OVER (ORDER BY names ASC) AS ROWID, *
from emp
except
SELECT ROW_NUMBER() OVER (ORDER BY names ASC) AS ROWID, *
FROM
(
select names , sal from emp
union
select distinct names,sal from emp) as a ) as b)
drop table #temp
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
What are the dis_advantages of stored procedures, triggers, indexes?
What is user-defined functions? What are the types of user-defined functions that can be created?
Is a primary key unique?
What is data file in computer?
What is user-defined function? Explain its types i.e. Scalar and inline table value user-defined function?
What is the beast way to write CTE in SQL Server ?
What happens to a trigger with multiple affected rows?
What is auditing in sql server?
Should you normalize audio?
Is there any difference between primary key and unique with the not null condition?
What are the limitations in ssrs on sql server express edition?
Define tool Manage Statistics in SQL Server 2000 query ?
what's sql server? : Sql server database administration
What is clustered vs nonclustered index?
between cast and convert which function would you prefer and why?