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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:19:09+00:00 2026-05-28T07:19:09+00:00

I have a table on another SQL server which I need to copy from

  • 0

I have a table on another SQL server which I need to copy from overnight. The structure of the destination table is very similar so I was just going to use something like the code below.
Source – http://forums.asp.net/t/1322979.aspx/1

I have not tried this yet, but is there a better/quicker way to do this in linq?

    //there exist two table list and listSecond
    DataClassesDataContext dataClass = new DataClassesDataContext(); //create the instance of the DataContext

    var str = from a in dataClass.lists select a;
    foreach (var val in str) // iterator the data from the list and insert them into the listSecond
    {
        listSecond ls = new listSecond();
        ls.ID = val.ID;
        ls.pid = val.pid;
        ls.url = val.url;
        dataClass.listSeconds.InsertOnSubmit(ls);

    }
    dataClass.SubmitChanges();
    Response.Write("success");
  • 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-28T07:19:09+00:00Added an answer on May 28, 2026 at 7:19 am

    Using LINQ to insert large amounts of data is not a good idea, except maybe with complicated schemas that need much transformations before being copied. It will create a separate query for each row inserted, in addition to logging them all in the transaction log.

    A much faster solution can be found here – it’s using SqlBulkCopy, which is a method for inserting large amounts of data in a single query, withouth transaction logging to slow it down. It will be an order of magnitude faster, and I’m telling you this from personal experience with both methods.

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

Sidebar

Related Questions

I have a SQL Server DB that has a table of products, and another
I have a table of information in a SQL Server database and another table
Another one for you SQL Server gurus... I have a table like so... AccountManager
In SQL Server 7.0, I need to find out which users have write access
Using C# (vs2005) I need to copy a table from one database to another.
I have database in XML, which I need export to SQL Server DB. So,
Nightly, I need to fill a SQL Server 2005 table from an ODBC source
I have a SQL Server table with the following structure cod_turn (PrimaryKey) taken (bit)
I have a table which defines what things another table can have, for example:
I have a table conditions, which defines some conditions. I have another table called

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.