SQL batch inserts in .NET.

Is using the .NET DataAdapter batch insertion functions more efficient than a round-trip DB compared to using DbCommand.ExecuteNonQuery () in a loop?

Coming from the Java world, I was hoping to find something similar to its batch capabilities when multiple SQL commands are sent to a database and executed in a single operation. When observing the database server, I see that the DataAdapter makes one instance for each insert.

I read several topics that use SqlBulkCopy, but which will only work for MS Sql Server.

Thanks!

+5
source share
2 answers

DataAdapter UpdateBatchSize. UpdateBatchSize .

, ...

+5

:

mysql:
INSERT INTO table (id) VALUES (1), (2), (3)

mssql:
INSERT INTO table (id)
SELECT 1
UNION ALL
SELECT 2
UNION ALL
SELECT 3
0

All Articles