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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:40:17+00:00 2026-05-10T22:40:17+00:00

I am attempting to insert a mass of records into SQL Server 2005 from

  • 0

I am attempting to insert a mass of records into SQL Server 2005 from Vb.Net. Although the insertion is working fine, I am doing my best to try to make it as fast as possible. Currently, it takes ~ 11 mins for 100,000 records. What would be the suggested approach to inserting a large number of records into SQL Server from an Application?

My current apporach is basically opening the connection, iterating through my list of information and firing off individual sql insert statments, and then closing the connection. Anyone have a better suggestion on how to do this?

Current Function:

Public Sub BatchInsert(ByVal ParamCollections As List(Of SqlParameter()))      Dim Conn As SqlConnection = New SqlConnection(DBHelper.DatabaseConnection)     Using scope As TransactionScope = New TransactionScope()     Using Conn          Dim cmd As SqlCommand = New SqlCommand('sproc_name', Conn)          Conn.Open()         cmd.CommandType = CommandType.StoredProcedure          For i = 0 To ParamCollections.Count - 1              cmd.Parameters.Clear()             cmd.Parameters.AddRange(ParamCollections(i))             cmd.ExecuteNonQuery()          Next          Conn.Close()         scope.Complete()     End Using     End Using  End Sub 
  • 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. 2026-05-10T22:40:17+00:00Added an answer on May 10, 2026 at 10:40 pm

    Use the SqlBulkCopy class, it will be able to run through those 100K rows much faster than individual inserts.

    Oh, and if you can, I would urge you to implement a IDataReader capable class, to feed the SqlBulkCopy.WriteToServer(IDataReader) method, this will allow you to produce data sequentially, one row at a time. If you are importing from a text file, as an example, building some IEnumerable<T> methods that uses yield return and converting it to a IDataReader object will allow you to feed data to the server very naturally.

    To counter the loss of rollback ability with BCP, you can transfer the data into a temporary table, and then execute normal INSERT INTO statements on the server afterwards, bulk-transferring the data from the temporary table into the production table, this will allow you to use a transaction for the last transfer part, and will still run a lot faster than your original individual insert statements.

    EDIT: and Here’s an example (C#, but should be easy to convert to VB.Net) of the usage of the bulk load API.

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

Sidebar

Related Questions

I am attempting to insert a row manually into my SQL Server data table.
I'm attempting to insert some data from MySQL to SQL Server. I've dumped the
I am attempting to insert a copy of a row from one table into
I am attempting to insert data into a local SQLITE database file from a
Attempting to insert an escape character into a table results in a warning. For
I am working on a legacy ASP application. I am attempting to insert a
Attempting to deploy a MOSS solution to a UAT server from dev server for
I'm attempting to insert some integers into a Postgres table with the following somewhat
I am attempting to insert a custom behavior into my service client, following the
I am attempting to insert a Canvas3D object inside a Swing JPanel, but the

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.