Verakso
Verakso

Reputation: 466

What is the fastest way to save data in SQL Server using C#?

I am currently working on a small .NET app in C#, that fetches data through some web service.

The data is represented in objects, so it would have been logical to store the data in a document based database, but there is a demand to use SQL Server.

So what might be the fastest way to insert many thousands, perhaps millions of rows into a database.

I an open to any framework, that might could support that, but I haven't been able to find any benchmarking on this e.g. on Entity Framework.

To iterate over the data an do an insert per row is simply to slow, then it would be quicker to dump the data in a file, and then do a bulk import using SSIS, but for this scenario I would rather avoid that, and keep all logic in the C# app.

Upvotes: 2

Views: 1054

Answers (1)

scartag
scartag

Reputation: 17680

You might want to use the SqlBulkCopy class. It is quite efficient for large data.

Upvotes: 4

Related Questions