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

How do you set a trace flag in sql server?

1043


Name and describe few console utilities for ssrs?

284


Can we use pragma autonomous_transaction in trigger?

971


Why do you need a sql server?

1116


how to restart sql server in single user mode? How to start sql server in minimal configuration mode? : Sql server database administration

915


what is difference between view and Dip.

2418


How to list all login names on the ms sql server?

1149


Explain about sql server login?

1094


What is a livelock?

975


What is 2nf normalization?

1033


How to update multiple rows with one update statement in ms sql server?

1215


How is a full-text index updated?

961


Explain the steps to use transact-sql cursor?

1073


What is the maximum number of instances in 32 bit and 64 bit sql server 2012?

993


How to create a login account in ms sql server to access the database engine using "create login" statements?

1151