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 a table,i want to delete 2 duplicate
records by keeping 1 duplicate and 1 original as it is,how?

Answer Posted / mohamed zunu

create table sampletbl(id int,name varchar(100))

insert into sampletbl values(1,'aa')
insert into sampletbl values(1,'aa')
insert into sampletbl values(1,'aa')


with cte as(
select ROW_NUMBER() over (partition by id order by id) as r_no,* from sampletbl)
delete from cte where r_no>1
select * from sampletbl

Is This Answer Correct ?    9 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the mathematical functions supported by sql server 2005?

1071


How to update values in a table with update statements in ms sql server?

1013


How can you list all the table constraints in a database?

938


Detail about the hardware which is supported by SQL server?

1063


Why I am getting this error when dropping a database in ms sql server?

1072


What to perform pattern match with the like operator?

883


Do you know what are the restrictions that views have to follow?

1079


What is scheduled job and how to create it?

993


Explain different backup plans?

943


How to write the storeprocedure with in the store procedure? and how can we write the store procedure with in a trigger vice versa? plz post me the exact answer?

2582


What are the underflow and overflow behaviors on float literals?

1113


Difference between connected and disconnected database in .net with sql server?

1095


wat wil hapn if we give the both read and deny read permission to user?

2103


Why use cursor in sql server?

1077


Will count(column) include columns with null values in its count?

1093