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
Can you tell me some of the common replication dmv's and their use? : sql server replication
What is dimension table? : sql server analysis services, ssas
What is wrong with sql server client libarary dll, ntwdblib.dll?
how to overcome kernel isssues
Explain partitioned view?
What is built-in/administrator?
Can you explain what are the restrictions applicable while creating views? : SQL Server Architecture
Why do we use trigger?
How can I add Reporting Services reports to my application?
Explain user defined functions?
What is the importance of concurrency control?
What are constraints in microsoft sql server?
Can binary strings be converted into numeric or float data types?
what are the reporting service components in SSRS?
How to call stored procedure using http soap?