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

Why do we use functions?

903


What is analysis service repository?

1018


How to sort query output in descending order in ms sql server?

938


How to verify the port number of the sql server?

1134


What are the new features in SQL Server 2005 when compared to SQL Server 2000?

1153


Is it true that rules do not apply to data already existing in a database at the time the rule is created?

1031


What is proper subset of candidate key?

990


what types of replication are supported in sql server? : Sql server database administration

1032


Explain indexes disadvantages?

1072


Describe how to use linked server?

1004


What do you mean by data manipulation language?

1004


How to configure and test odbc dsn settings?

1149


What are the advantages of sql stored procedure?

1060


What is a trigger and types of a trigger?

975


I create a separate index on each column of a table. What are the advantages and disadvantages of this approach? : Sql server database administration

1077