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
How to divide query output into multiple groups with the group by clause in ms sql server?
How to drop an existing schema in ms sql server?
do you know how to configure db2 side of the application? : Sql server database administration
Does windows server 2016 come with sql server?
What is an indexing strategy?
What is difference between rownum and rowid?
role of sql sever 2005 in database rather than any other database
Detail about the hardware which is supported by SQL server?
How to concatenate two character strings together?
Is it possible to update the views? If yes, how, if not, why?
Detail about query optimizer?
What is the purpose of forms?
What is scalar user-defined function?
Does partitioning ssd reduce performance?
What is policy management?