• riya_dave (7/17/2013)


    total i have 60 millions rows from there i need to insert 30 millions to some another table.

    once it is insert i need to delete it from original table

    You can do the delete/insert in the same statement like so:

    DELETE TOP (100000) FROM LiveTable

    OUTPUT deleted.* INTO ArchiveTable

    WHERE ...

    --batched up so it doesn't choke up your resources.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden