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

How to replace null values in expressions using isnull()?

1063


What is equi join with example?

1036


Can you explain about buffer cash and log cache in sql server?

913


what is database replicaion? What are the different types of replication you can set up in sql server? : Sql server database administration

933


What is similarity and difference between truncate and delete in sql?

1053


Do you know what is replace and stuff function in sql server?

965


How you trouble shoot when any job fails

1908


whats the maximum size of view state??

2155


What is transaction server distributed transaction?

995


What is the difference between grant and with grant while giving permissions to the user?

912


Differentiate between sql temp table vs table variable?

848


What command do we use to rename a db, a table and a column?

885


How to change the ownership of a schema in ms sql server?

1115


What are the different types of indexes?

1059


How do you use a subquery to find records that exist in one table and do not exist in another?

1003