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

How to delete the duplicate rows from a table in SQL Server ??

Answer Posted / vnreddy

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')
insert into sampletbl values(2,'bb')
insert into sampletbl values(2,'bb')

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 ?    10 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what are commit and rollback in sql?

931


How to write a query with a left outer join in ms sql server?

979


Distinguish between commit and rollback?

956


What is ms sql server reporting services?

1053


Which autogrowth database setting is good?

1058


What is filtered index?

1091


What do you do in data exploration

987


Can you explain what is indexed view? How to create it?

897


Why is there a performance difference between two similar queries where one uses union and the other uses union all?

1031


Explain few of the new features of sql server 2008 management studio

912


What is after dml trigger?

1012


How can you transfer data from a text file to a database table? Or how can you export data from a table to a comma delimited (csv) file? Or how can you import data from ms access to a table in a database? Or how can you export data from a table to an excel file?

1027


What are two difference between sql azure and azure tables?

159


What are scalar functions in sql?

1143


What is default port number for sql server 2000?

1044