Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Deleting Duplicate Rows Expand / Collapse
Author
Message
Posted Friday, October 31, 2003 12:00 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, April 14, 2010 10:28 AM
Points: 188, Visits: 4
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/darjun/deletingduplicaterows.asp

Deepak Arjun
Mobile (+91) 09885088054
Post #17816
Posted Friday, November 7, 2003 2:06 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, June 15, 2011 4:12 AM
Points: 5, Visits: 12
why not just Union the table with itself?




Post #85576
Posted Friday, November 7, 2003 2:20 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, December 12, 2005 4:42 AM
Points: 5, Visits: 1
Thanks for that, seems less hassle to do it this way.




Post #85577
Posted Friday, November 7, 2003 3:08 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, March 23, 2006 6:53 AM
Points: 348, Visits: 1
In this particular case, you could do:

select distinct *
from OrderDetail

The problem with removing duplicates is that there are so many variations that no one solution fixes all. You just need to be aware of different ways of achieving the same result.



Jeremy




Post #85578
Posted Friday, November 7, 2003 7:20 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Saturday, October 23, 2010 4:51 AM
Points: 80, Visits: 58
Mr deepak can have a look into
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=6256




Post #85579
Posted Friday, November 7, 2003 8:44 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, April 14, 2010 10:28 AM
Points: 188, Visits: 4
Thanks for all the comments on this article. Ofcourse there are lots of ways to delete multiple records and this method is only one of the approaches.
But every methods used depends on table size, no of columns and ease of convenience. For this method,You need not write cursors, tricky queries.It is fast bcos it uses bulk copy operation and it holds true for every table with duplicate rows with any number of duplicate columns.


quote:

Mr deepak can have a look into
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=6256







Deepak Arjun
Mobile (+91) 09885088054
Post #85580
Posted Sunday, November 7, 2004 9:18 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Monday, November 20, 2006 11:09 PM
Points: 220, Visits: 1

Mr deepak good work .might be other ways to do the process.but this way is simple and its userfriendly isnt.

Post #145111
Posted Wednesday, April 28, 2010 7:06 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, June 15, 2010 2:18 AM
Points: 15, Visits: 21
The query will be composed this way:-


WITH TempUsers (FirstName,LastName, duplicateRecordCount)
AS
(
SELECT FirstName,LastName,
ROW_NUMBER()OVER(PARTITIONBY FirstName, LastName ORDERBY FirstName) AS duplicateRecordCount
FROM dbo.Users
)
DELETE
FROM TempUsers
WHERE duplicateRecordCount > 1
GO



Instead of TempUsers you can give any name. Because this is used only for Temporary purpose.


Cheers,
Bijayani
Proud to be a part of Team Mindfire.

Mindfire: India's Only Company to be both Apple Premier & Microsoft Gold certified.
Post #911905
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse