0

What is the fastest method for copying data between databases in c#? I want to create c# database procedure than accepts query string as parameter and inserts data to another database (sql query and destination table will have the same columns).

I use SQLBulkCopy right now but causes some problems.

spdro
  • 460
  • 1
  • 5
  • 8

1 Answers1

0

I know you've asked about C# in your post, but you might want to consider a couple of other methods, using the stored procedure you are about to create. All of the below would be in the stored procedure itself.

Have you considered a T-SQL approach using OPENROWSET() That way, you never have to pull the data back over to C# and send it back over to SQL server. You will find some recommendations from Microsoft here and here is the specific link using OPENROWSET()

If you want to use C# still, you can also use SSIS, which has an ability to copy data in bulk mode between servers, and you can call it from C# using the appropriate package you'd have to create (visual workflow). Please see this thread for details.

Community
  • 1
  • 1
dawebber
  • 3,398
  • 1
  • 14
  • 16