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
Are semicolons required at the end of sql statements in sql server 2005?
Explain Geometry datatype in sql server 2008 with example
What is difference between joins and subqueries?
How to invoke a trigger on demand?
When a primary key constraint is included in a table, what other constraints does this imply?
Can we write ddl in trigger?
What is the difference between varchar and nvarchar datatypes?
Explain about nested stored procedure?
Where can you find the error log information? : sql server database administration
Which language is supported by sql server?
What is an active database?
What is the command used to recompile the stored procedure at run time?
What are the advantages of stored procedure in sql server?
Should you normalize audio?
as a part of your job, what are the dbcc commands that you commonly use for database maintenance? : Sql server database administration