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...

if 3 duplicate records in table,i want to delete 2 alternating
duplicate records by keeping 1 duplicate and 1 original as it
is,how?

Answer Posted / sivam

sno sname salary
1 aaa 1000
1 aaa 1000
2 bbb 2000
2 bbb 2000
2 bbb 2000
1 aaa 1000

;with aa as
(
select sname,salary,ROW_NUMBER()over(partition by sno,sname,salary order by sno,sname,salary) as Nos from #testtable
)

delete from aa where Nos%2<>0

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain how does the report manager work in ssrs?

999


What is SQL Server?

1273


What is ssrs?

135


Why is replication required on the sql server?

1107


How to backup encryption key ?

191


What are sql dirty pages?

1081


How to rename an existing table with the "sp_rename" stored procedure in ms sql server?

1074


Difference between drill down and drill through report.

1007


What do you mean by the term 'normalization'?

1284


How to modify the underlying query of an existing view?

1030


What is an identity?

1079


How to write an inner join with the where clause in ms sql server?

1166


How do database indexes work?

1058


Explain raiserror in sql server?

1079


How to defragment indexes with alter index ... Reorganize?

1137