• kit-1143032 (10/8/2013)


    I am wondering if anyone has used this in a CTE?

    Absolutely! Using Row_Number with a CTE is a great combination.

    ;with cte as

    (

    Select *,

    Row_Number() over (Partition By Last_Name, First_Name, Age Order by Last_name) RowNum

    From TableName

    )

    Delete From cte Where RowNum > 1

    This is a VERY simplified example, but you should see how it could be applicable to a number of scenarios you may come up against.

    __________________________________________________________________________________________________________
    How to Post to get the most: http://www.sqlservercentral.com/articles/Best+Practices/61537/