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 retrieve duplicate rows in a table?
How to delete the duplicate entries in a table?

Answers were Sorted based on User's Feedback



How to retrieve duplicate rows in a table? How to delete the duplicate entries in a table?..

Answer / mon

DELETE FROM MyTable
LEFT OUTER JOIN (
SELECT MIN(RowId) as RowId, Col1, Col2, Col3
FROM MyTable
GROUP BY Col1, Col2, Col3
) as KeepRows ON
MyTable.RowId = KeepRows.RowId
WHERE
KeepRows.RowId IS NULL

Is This Answer Correct ?    0 Yes 0 No

How to retrieve duplicate rows in a table? How to delete the duplicate entries in a table?..

Answer / arun kumar k s

drop table #TEMP select distinct * into #TEMP from
TABLE_NAME delete from TABLE_NAME insert into TABLE_NAME
select * from #TEMP

Is This Answer Correct ?    0 Yes 3 No

How to retrieve duplicate rows in a table? How to delete the duplicate entries in a table?..

Answer / gaurav jain

begin
select distinct * into #one from four where id in (select
id from four group by id
having count(*)>1)
delete from four where id in (select id from four group by
id having count(*)>1)
insert into four select * from #one
end

Is This Answer Correct ?    0 Yes 3 No

How to retrieve duplicate rows in a table? How to delete the duplicate entries in a table?..

Answer / anoop rajan

Tbale emp had some duplicate entries and i wanted to retain
the first of all duplicates, the others could be deleted as
follows . Please give your comments if this is the most
optimum way :

delete from emp where rowid in
(select rowid from emp o where rowid !=
(select min(rowid) from emp i where i.empno=o.empno));

Is This Answer Correct ?    0 Yes 3 No

How to retrieve duplicate rows in a table? How to delete the duplicate entries in a table?..

Answer / pawan k. dubey

delete from employee
where Emp_id not in (select min(Emp_id) from employee
group by Emp_Name)

Is This Answer Correct ?    2 Yes 12 No

Post New Answer

More SQL Server Interview Questions

Can you explain about buffer cash and log cache in sql server?

0 Answers  


What is usually the first word in a sql query?

0 Answers  


How do I shrink an ldf file?

0 Answers  


How to declare and use cursor variables?

0 Answers  


You have a stored procedure, which execute a lengthy batch job. This stored procedure is called from a trigger you do not want to slow the data entry process you do not want trigger to wait for this batch job to finish before it completes itself what you can do to speed up the process?

0 Answers  


What are the database objects? : SQL Server Architecture

0 Answers  


How ssrs maintain security?

0 Answers  


What is difference between cte and view?

0 Answers  


What is the log shipping?

0 Answers  


What is difference between getdate and sysdatetime in sql server 2008?

0 Answers  


OPTIMIZATION OF SP,CURSOR,TRIGGERS

0 Answers  


what is differencial backup?how to work?Anybody explai it?

2 Answers   HCL,


Categories