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

Are semicolons required at the end of sql statements in sql server 2005?

932


Explain Geometry datatype in sql server 2008 with example

918


What is difference between joins and subqueries?

1050


How to invoke a trigger on demand?

1026


When a primary key constraint is included in a table, what other constraints does this imply?

938


Can we write ddl in trigger?

864


What is the difference between varchar and nvarchar datatypes?

1033


Explain about nested stored procedure?

975


Where can you find the error log information? : sql server database administration

970


Which language is supported by sql server?

954


What is an active database?

961


What is the command used to recompile the stored procedure at run time?

1016


What are the advantages of stored procedure in sql server?

832


Should you normalize audio?

879


as a part of your job, what are the dbcc commands that you commonly use for database maintenance? : Sql server database administration

857