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 replace null values in expressions using isnull()?
What is equi join with example?
Can you explain about buffer cash and log cache in sql server?
what is database replicaion? What are the different types of replication you can set up in sql server? : Sql server database administration
What is similarity and difference between truncate and delete in sql?
Do you know what is replace and stuff function in sql server?
How you trouble shoot when any job fails
whats the maximum size of view state??
What is transaction server distributed transaction?
What is the difference between grant and with grant while giving permissions to the user?
Differentiate between sql temp table vs table variable?
What command do we use to rename a db, a table and a column?
How to change the ownership of a schema in ms sql server?
What are the different types of indexes?
How do you use a subquery to find records that exist in one table and do not exist in another?