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

Does group by or order by come first?

0 Answers  


Explain the use of keyword with encryption. Create a store procedure with encryption?

0 Answers  


What are the different subsets of sql?

0 Answers  


Define right outer join in sql server joins?

0 Answers  


What is SubQuery in SQL Server 2008

0 Answers   HCL,


What are the hotfixes and patches in sql server?

0 Answers  


How do you load large data to the SQL server database?

2 Answers  


Describe the functionalities that views support.

0 Answers  


What are recommended options to be used while using db mirroring? : sql server database administration

0 Answers  


How data can be copied from one table to another table?

0 Answers  


Can the “if update (colname)” statement be used in a delete trigger?

0 Answers  


Say if we have a table that contains only a single column , say OrderID, which has IDENTITY attribute defined on it. So how can we insert data in this table. I am reframing my question, that how can we make the table to increment the column "OrderID" value several times???

3 Answers  


Categories