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

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / sudha511

select distinct * into #temp from sampletbl
delete sampletbl
insert into sampletbl
select * from #temp
drop table #temp

Is This Answer Correct ?    2 Yes 0 No

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

Answer / himmat

delete from table name
having count(column name)>1
group by column name

Is This Answer Correct ?    15 Yes 25 No

Post New Answer

More SQL Server Interview Questions

How do we return a record set from a Stored Procedure in SQl server 2000?

3 Answers  


how to control the amount of free space in your index pages? : Sql server database administration

0 Answers  


Can you explain the disadvantages/limitation of the cursor?

0 Answers  


Please explain go command in sql server?

0 Answers  


What is database replicaion? What are the different types of replication you can set up in SQL Server?

5 Answers   Aptech, HCL, Perpetual, SAIC,


How to check if a table is being used in sql server?

0 Answers  


Please differentiate between a local and a global temporary table?

0 Answers  


What is meant by datasource?

0 Answers  


How to view existing indexes on an given table using sys.indexes?

0 Answers  


What types of integrity are enforced by a foreign-key constraint

1 Answers  


What is difference between clustered index and non clustered index?

0 Answers  


explain different types of backups avaialabe in sql server? Given a particular scenario, how would you go about choosing a backup plan? : Sql server database administration

0 Answers  


Categories