using temporary tables in storeprocedure

  • How to delete the duplicate rows from the table using the storeprocedure and by using temporary tables.....but I do not want to use the cursors as cursors are taking much memory...

    Thanks

    Bhavin

  • Hi you can using the CTE and Function of Ranking

    Example :

    ;WITH Duplicate AS

    (

    SELECT

    *, rownumber = ROW_NUMBER() OVER(PARTITION BY yourFieldvalue ORDER BY id)

    FROM Table1

    )

    DELETE

    FROM Duplicate

    OUTPUT DELETED.id, DELETED.yourFieldvalue

    WHERE rownumber > 1

    By Giorgio

  • Thank you very much.

Viewing 3 posts - 1 through 3 (of 3 total)

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