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

How you can get the list of largest tables in a database?

1062


What is stretch database in sql server?

1117


When would you use a before or after trigger?

953


List out different types of normalizations in sql server and explain each of them?

970


What is for xml in sql server?

1136


What is the need for indexing?

986


How to provide values to stored procedure parameters in ms sql server?

1094


How many files can a database contain in sql server?how many types of data files exists in sql server? How many of those files can exist for a single database?

1208


In what sequence sql statement is processed?

1055


What’s the distinction between dropping a info and taking a info offline?

1090


What are the database roles? : sql server security

1273


Explain the cursor lock types?

1097


How to transfer a table from one schema to another?

1045


What is the difference between coalesce() & isnull()?

1185


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

980