Find and Remove Duplicate Records SQL Server

  • Always can use this, thanks.

  • patrickmcginnis59 10839 (2/3/2016)


    Jeff Moden (2/2/2016)


    andy_111 (1/31/2016)


    Not really useful article.

    Not really a useful comment, either. Please explain why you think it's not useful.

    I have to agree with andy_111's sentiment, he and others noted the row number / windowing function alternative, and additionally I think that with the warnings about SET ROWCOUNT's changing semantics, the original posted code is probably a trap for the unwary.

    Also deleting dupes is sort of a FAQ and I don't think the author really covered the material, especially given what I've seen with a basic web search on the topic. Clearly the windowing functionality should have been mentioned, heck even Microsoft offers the selecting distinct into a temp table, deleting and reinserting as an option in one of their older pages. Given the shakey semantics lifetime of SET ROWCOUNT on updates, I think a decent effort should have discussed this, so I have to in general agree with andy_111's sentiment.

    It looks like an old fashion article, doesn't it? For SQL 2000 or something.

    Even with that, I like the insert distinct copies of the dupes into a temp table, remove the dupes, then reinsert back into the source if we're talking about non windowing function methods. Still yeah, a bit on the old fashioned side 🙂

    Now that's the kind of disagreement I can respect instead of a useless "poop" bomb with no info like the original commment. 🙂 Glad he followed up after that.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)
    Intro to Tally Tables and Functions

Viewing 2 posts - 76 through 76 (of 76 total)

You must be logged in to reply to this topic. Login to reply