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
To which devices can a backup be created and where should these devices be located? : sql server management studio
What do you mean by data manipulation language?
What are triggers in ms sql server?
What is the difference between a local and a global temporary table?
I have all the primary data files, secondary data files as well as logs. Now, tell me can I still restore the database without having a full backup? : sql server database administration
Do you know what are the properties of the relational tables?
Explain the architecture of ms sql reporting service?
How to copy the tables, schema and views from one sql server to another?
How to create a dml trigger using create trigger statements?
How to apply filtering criteria at group level with the having clause in ms sql server?
List out a number of the wants to setup a SQL Server failover cluster?
Can foreign key be deleted?
What are the different types of locks in the database?
Why would you use sql agent?
Explain can SSRS reports Cache results?