Geeks Talk

Prepare for your Next Interview




How can we delete the duplicate data from a database table?

This is a discussion on How can we delete the duplicate data from a database table? within the SQL Server forums, part of the Databases category; To delete the duplicate data we may use the temporory tables, but with out using any teporory tables can we delete the duplicated data, if how it is possible?...


Go Back   Geeks Talk > Databases > SQL Server

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 04-23-2008
Junior Member
 
Join Date: Apr 2008
Location: Hyderabad
Posts: 20
Thanks: 1
Thanked 2 Times in 2 Posts
nageshkota is on a distinguished road
Post How can we delete the duplicate data from a database table?

To delete the duplicate data we may use the temporory tables, but with out using any teporory tables can we delete the duplicated data, if how it is possible?

Last edited by nageshkota : 04-23-2008 at 09:14 AM.
Reply With Quote
The Following User Says Thank You to nageshkota For This Useful Post:
Sponsored Links
  #2 (permalink)  
Old 04-23-2008
Moderator
 
Join Date: Jun 2007
Location: Bangalore,India
Posts: 1,330
Thanks: 7
Thanked 120 Times in 108 Posts
debasisdas will become famous soon enoughdebasisdas will become famous soon enough
Re: How can we delete the duplicate data from a database table?

Kindly post what you have tried so far for further discussion on the topic.
Reply With Quote
  #3 (permalink)  
Old 06-20-2008
Junior Member
 
Join Date: Jun 2008
Location: Chandigarh
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
RajneshBansal is on a distinguished road
Re: How can we delete the duplicate data from a database table?

;with DelDup as (select row_number() over (partition by
ID order by ID) as RowNo from duplicateTest )
Delete from DelDup where RowNo> 1
Reply With Quote
  #4 (permalink)  
Old 06-20-2008
Banned
 
Join Date: Jun 2008
Location: indiachennai
Posts: 6
Thanks: 1
Thanked 1 Time in 1 Post
ramyaselvi16 is on a distinguished road
Re: How can we delete the duplicate data from a dataobase table in Oracle ?

DELETE FROM emp WHERE rowid NOT IN (SELECT max(rowid) FROM emp GROUP BY id);
Reply With Quote
  #5 (permalink)  
Old 06-23-2008
Junior Member
 
Join Date: Jun 2008
Location: Bangalore
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
jacky4u is on a distinguished road
Re: How can we delete the duplicate data from a database table?

To delete the duplicate data you can use this sql query: method 1 :delete from categories where categories.id not in (select min(c.id) from categories as c where categories.category_name = c.category_name) method 2: set rowcount syntax for set rowcount is as follows: set rowcount { number | @number_var } set rowcount 3 delete from users where firstname = n'elvis' and lastname = n'presley' set rowcount 0 -- (3 row(s) affected)
Reply With Quote
  #6 (permalink)  
Old 07-15-2008
Junior Member
 
Join Date: Jul 2008
Location: India
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Antony Michael Prakash is on a distinguished road
Re: How can we delete the duplicate data from a database table?

Quote:
Originally Posted by nageshkota View Post
To delete the duplicate data we may use the temporory tables, but with out using any teporory tables can we delete the duplicated data, if how it is possible?
DELETE FROM wikis_details
WHERE wiki_id in
(SELECT wiki_id
FROM wikis_details
GROUP BY wiki_id
HAVING count(wiki_id)>1)
Reply With Quote
  #7 (permalink)  
Old 07-22-2008
Junior Member
 
Join Date: Jul 2008
Location: new delhi
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
chetan6002 is on a distinguished road
Re: How can we delete the duplicate data from a database table?

using rowid
Reply With Quote
Reply

  Geeks Talk > Databases > SQL Server


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
Delete duplicate record raghvendra_rai SQL Server 15 03-20-2008 10:29 PM
How to delete duplicate rows in a table saritha_racharla SQL 6 11-21-2007 01:48 AM
How can I compare the data table values with Database sanathsharma QTP 0 07-12-2007 05:33 AM
Delete duplicate records without using "rowid" Geek_Guest SQL 7 07-12-2007 03:06 AM
I want load the duplicate records to seperate table Geek_Guest Data Warehousing 4 04-06-2007 02:10 AM


All times are GMT -4. The time now is 10:47 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved