Reputation: 38
I want to insert 65545 rows from csv to SQL Server 2008 in C#.net but I need to rearrange data in my program.
Which way is the best way to insert those rows into SQL Server, SQLBulkOperations, or using transaction and insert row by row, or using multi insert.
Upvotes: 1
Views: 542
Reputation: 8928
65K rows is not that many really, but I suggest using System.Data.SqlClient.SqlBulkCopy
because it's fast now, and also fast later when your requirements expand. It's also handy to keep an implementation of it around - this sort of thing seems to come up fairly regularly.
I have an answer to another SO question that has psuedocode describing how I used SqlBulkCopy in my last big project:
Sql server 2008 - performance tuning features for insert large amount of data
It sounds like you want to do the same sort of thing as I, except reading the data from a CSV rather than another database file. Look into a good CSV parsing library for a performant solution to that part of the problem. Good luck!
Upvotes: 3