Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What are the dis_advantages of stored procedures, triggers, indexes?

2226


What is user-defined functions? What are the types of user-defined functions that can be created?

1035


Is a primary key unique?

992


What is data file in computer?

948


What is user-defined function? Explain its types i.e. Scalar and inline table value user-defined function?

906


What is the beast way to write CTE in SQL Server ?

1046


What happens to a trigger with multiple affected rows?

946


What is auditing in sql server?

928


Should you normalize audio?

943


Is there any difference between primary key and unique with the not null condition?

952


What are the limitations in ssrs on sql server express edition?

186


Define tool Manage Statistics in SQL Server 2000 query ?

1094


what's sql server? : Sql server database administration

1000


What is clustered vs nonclustered index?

948


between cast and convert which function would you prefer and why?

956