Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Efficiency when inserting huge data into a database

Tags:

c#

sql-server

When I want to insert huge amount of data into database, which way is more efficient? 1. insert data row by row by calling insert statement 2. create a user defined Table type in my database, and write a stored procedure to insert a DataTable into database. and why?

like image 452
Philip Zhang Avatar asked Jun 30 '26 13:06

Philip Zhang


1 Answers

The most efficient would be SQL Bulk Insert.

To improve the performance further you can use SqlBulkCopy to SQL Server in Parallel.

like image 62
maximpa Avatar answered Jul 03 '26 02:07

maximpa