Insert data into multiple tables after each batch of 100000 rows

  • Hello!

    I have a table with 2 million rows. I need to insert data into new table for each batch of 100000 rows.

     

     

    Thanks in advance.

     

  • PJ_SQL wrote:

    Hello!

    I have a table with 2 million rows. I need to insert data into new table for each batch of 100000 rows.

    Thanks in advance.

    This is a requirement, not a question! Which part of this are you having trouble with and what have you tried so far?

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • I also have to ask "WHY"?  Why do you need to "batch" this instead of just doing all 2 million rows, which most servers can easily handle?

    And the reason why we ask such questions is because it will help us identify the best way possible to accomplish your task while, at the same time, possibly get you thinking that there might be a better way.

    For example, a lot of people have started posts with "I need to iterate over the rows of a table...".  In most cases, it turned out that the use of such RBAR was totally unnecessary and a set-based solution turned out to be far superior to what the OP thought was necessary.

    --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)

  • This was removed by the editor as SPAM

  • Hasali wrote:

    I'm especially stayed aware of the article and I will get many benefits from it. Subsequently, thank you for sharing it.

    Huh? I don't understand what you're saying. It doesn't seem to answer any of the questions asked.

    Anyway, you might gain some insights into how to do "paging" in a select by reading this article:

    https://www.microsoftpressstore.com/articles/article.aspx?p=2314819

    However, this is no substitute for the insights you may be gaining by allowing us to help you with your particular problem. But to help you we need more information about your scenario than you have provided thus far.

     

    • This reply was modified 1 year, 6 months ago by  kaj. Reason: Typo
  • Hasali wrote:

    I'm especially stayed aware of the article and I will get many benefits from it. Subsequently, thank you for sharing it.

    This is a prelude to SPAM.  It's becoming more and more common.

    --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)

Viewing 6 posts - 1 through 5 (of 5 total)

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