• You might want to look at using a CTE such as:

    ;with numbered as(SELECT rowno=row_number() over

    (Partition by COL1, COL2,COL3 order by COL1),COL1,COL2, COL3,COL4 FROM #TableX)

    SELECT COL1, COL2, COL3, COL4 from numbered

    WHERE Rowno > 1

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]