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 create a login account in ms sql server to access the database engine using "create login" statements?

1153


How to override dml statements with triggers?

1203


What is rank function?

1043


Can we use max in where clause?

943


What is a derived table?

937


How to delete an existing row with delete statements in ms sql server?

1109


How to generate random numbers with the rand() function in ms sql server?

1165


How to view the error log for any specific instance? : sql server database administration

1053


Write a SQL query to make a column as unique?

1047


Difference between Inner vs outer joins?

959


How do I delete a sql server database?

1053


What are subqueries in sql server?

1134


Why do we need different type of parameter?

1063


What are the acid properties?

1016


How to use old values to define new values in update statements in ms sql server?

1284