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
Mention the differences between local and global temporary tables.
How to delete existing rows in a table?
Does group by sort data?
What are the acid properties?
How to recover from sql injection? : sql server security
Is truncate a dml command?
What is view in sql?
What is the user of Primary key?
What are sub reports?
What is a transactions?
How to execute stored procedure and set temp table in sql server?
Can I use sql azure as a backup with log shipping or database mirroring?
Explain “not null constraint” in sql server?
Explain the database you used in your final year project?
What is a constant or literal in ms sql server?