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 delete duplicate record from a particular table?

Answer Posted / kala suresh

--BY USING A TEMP TABLE TO DELETE DUPLICATE ROWS OF A TABLE
WITH OUT A PRIMARY KEY COLUMN OR AN IDENTITY COLUMN

SELECT Name, age, ROW_NUMBER() OVER(ORDER BY age) AS
'RowNumber' into #temp1 FROM RowNumber

delete from #temp1 where rownumber not in(select
max(rownumber) from #temp1 group by name,age)

delete from rownumber

select * from #temp1 into rownumber

drop table #temp1


--BY USING AN IDENTITY COLUMN TO DELETE DUPLICATE ROWS OF A
--TABLE WITH OUT A PRIMARY KEY COLUMN

delete from rownumber where id not in(select min(id) from
rownumber group by name,age)
select * from rownumber

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the contrast between sql and mysql?

1157


How to create a view with data from multiple tables?

1063


What is single-user mode?

981


Write an sql query to find first weekday of the month?

975


What is query and its types?

954


Explain linked server in sql?

1293


Define left outer join in sql server joins?

1010


What is the difference between count and distinct count?

929


What is the difference between char, varchar and nvarchar?

1076


What are SSL and TSL protocols?

1033


What is the use of commit?

1061


What are the differences between web role and worker role?

124


Explain primary key?

1005


Explain the difference between clustered and non-clustered index?

968


Why truncate is ddl?

1133