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

Can we call future method from trigger?

881


How to convert a numeric expression from one data type to another?

934


List few advantages of stored procedure.

928


Can we call stored procedure in trigger?

909


When we should use and scope of @@identity?

953


How to drop an existing user defined function in ms sql server?

982


What are the differences between stored procedure and view in sql server?

1161


How to execute stored procedure and set temp table in sql server?

994


What is the use of toad or sqldbx.?

1102


What is a deadlock and what is a live lock?

952


Explain how would you store your query in an SSRS report or a Database server?

114


what is database replicaion? What are the different types of replication you can set up in sql server? : Sql server database administration

926


How will you monitor replication latency in transactional replication? : sql server replication

1089


What are cascading parameters in ssrs reports?

212


Write a sql query to delete duplicate records from a table called table1

975