Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8170205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:05:16+00:00 2026-06-06T21:05:16+00:00

How do I make SQL Server commit inserts in chunks? I need to copy

  • 0

How do I make SQL Server commit inserts in chunks? I need to copy a large amount of rows from an old db into a new table, and it has several problems:

  1. it takes ages to finish, and I don’t see any rows in my table until the entire transaction is finished.

  2. my log file is growing like crazy and it will probably run out of space.

  3. if something breaks in the middle, I have to repeat everything.

If I add SET ROWCOUNT 500, I can limit the number of rows, but I don’t know how to continue with the last inserted ID. I might query the new table to see what got inserted last, but I am not sure if that’s the right thing to do. And it’s a bit difficult because my where clause does not use the ID column, so I am not sure how to know exactly where to continue.

What’s the best approach for this? Is there a “for loop” or something which would allow me to commit every once in a while?

I am using SSMS for SQL Server 2008 R2.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T21:05:17+00:00Added an answer on June 6, 2026 at 9:05 pm

    Even if TomTom’s answer is sarcastic, it contains two basic options, which may help you:

    1. You can write a loop in T-SQL (see for example while) and use TOP and OFFSET to select chunks (you need an order by). You can minimize looging according to Microsoft. And if you just worry about restarting without redoing everything this should be fine, though I don’t expect it to be fast.

    2. You can export your selection to a file and use the bulk insert to load it.

    Some more options you may find here (About Bulk Import and Bulk Export Operations) and here (INSERT Section Best Practices).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I make an SQL server database, 1) Do I need to install SQL
We need to make some instances of our SQL Server invisible, so you can't
SQL Server 2008r2 Express SP1. I need to make a sting with list of
How do I make SQL SERVER 2005 to ignore the backslash in the following
I'm trying to make a connection to a SQL Server Express DB on localhost,
Delphi 2010, dbExpress, and SQL Server 2005 DB I am trying to make a
How can i make a SQL query from actionscript? and render all the results
I have many .NET processes reading messages from an SQL Server 2008 DB table
I'm trying to make my SQL Server table datetime columns save datetime with AM/PM.
I have a problem when I commit and rollback a transaction in SQL Server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.