October 31, 2003 at 12:00 am
Comments posted to this topic are about the content posted at http://www.sqlservercentral.com/columnists/darjun/deletingduplicaterows.asp
Deepak Arjun
Mobile (+91) 09885088054
November 7, 2003 at 2:06 am
why not just Union the table with itself?
November 7, 2003 at 2:20 am
Thanks for that, seems less hassle to do it this way.
November 7, 2003 at 3:08 am
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
November 7, 2003 at 7:20 am
Mr deepak can have a look into
November 7, 2003 at 8:44 am
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 intohttp://www.sqlteam.com/forums/topic.asp?TOPIC_ID=6256
Deepak Arjun
Mobile (+91) 09885088054
November 7, 2004 at 9:18 pm
Mr deepak good work .might be other ways to do the process.but this way is simple and its userfriendly isnt.
April 28, 2010 at 7:06 am
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.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply