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 a database be shrunk with users active? : Sql server administration
What is self join in sql server joins?
What is nested transaction?
What is an identity?
what are the core components of SSRS?
How to find table changes in sql server?
What is “begin trans”, “commit tran”, “rollback tran” and “savetran”?
What is the datatype of rowid?
What command is used to create a database in the sql server and how?
Define tempdb database?
How to provide default values to stored procedure parameters?
How do indexes help, types?
What is forward - only cursors / read only cursor?
What are trace files?
What is normalization? Explain its different types?