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 3681922
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:44:20+00:00 2026-05-19T03:44:20+00:00

I am trying to figure out how I could breakup my datatable and send

  • 0

I am trying to figure out how I could breakup my datatable and send that (as UDT) down to sql server). So if I have 100,000 in my datatable I would like to be able to break it up into 10,000 chunks to send down to my sql server. I am just not sure about how I would take the datatable with 100,000 and break it up into those 10,000k blocks?

Any suggestions would be greatly appreciated.

So if I used something like this:

var results = (from myRow in myDataTable.AsEnumerable()
              select myRow).take(10000);

Not sure how I could ensure I grabbed the next set of 10,000 rows from the datatable and ensure I don’t send duplicates and get all of the rows?

  • 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-05-19T03:44:20+00:00Added an answer on May 19, 2026 at 3:44 am

    Just write yourself a simple method to turn any collection into chunks of a specified size:

    /// <summary>Splits a collection into chunks of equal size. The last chunk may be smaller than chunkSize, but all chunks, if any, will contain at least one element.</summary>
    public static IEnumerable<IEnumerable<T>> Chunk<T>(this IEnumerable<T> source, int chunkSize)
    {
        if (chunkSize <= 0)
            throw new ArgumentException("chunkSize must be greater than zero.", "chunkSize");
        return chunkIterator(source, chunkSize);
    }
    private static IEnumerable<IEnumerable<T>> chunkIterator<T>(IEnumerable<T> source, int chunkSize)
    {
        var list = new List<T>();
        foreach (var elem in source)
        {
            list.Add(elem);
            if (list.Count == chunkSize)
            {
                yield return list;
                list = new List<T>();
            }
        }
        if (list.Count > 0)
            yield return list;
    }
    

    And then you can trivially use this, for example:

    foreach (var chunk in myDataTable.AsEnumerable().Chunk(10000))
    {
        // Process the chunk
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to figure out how I could poll for changes that are
I'm trying to figure out how to better parse lines of text that have
I'm trying to play with inter-process communication and since I could not figure out
Trying to figure out how to write a jquery formula that will sum all
I'm trying to figure out how could many boost classes be able to accept
I'm trying to figure out where I could drop in some PHP code to
I'm trying to figure out how I could create a curl or peel effect
I am new to Mercurial and trying to figure out if it could replace
right now I'm just trying to figure out how I could do the following
I'm trying to figure out how I could detect whether people logging into my

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.