Bulk inserting data into SQL Server using C#
In the last few days I had a question: what is the most fastest method to bulk insert data into a SQL Server database using C#? I decided to gather up all methods that I could find and do a very simple performance test to decide which one is the fastest.
Here are my results for inserting 10000 rows over 500 iterations:
Method | Time |
---|---|
SqlBulkCopy class | 137.022 ms |
bcp utility | 146.876 ms |
Table-Valued Parameter | 150.900 ms |
Simple.Data | 208.320 ms |
XQuery | 235.490 ms |
My configuration: