Problem: How to most efficiently move data from an array into a SQL Server table.
Details: I have created an array with many rows (typically, about 100,000) and many columns (about 40) in memory in a WinForms application. I need to get this array into a corresponding SQL Server table in the fastest way possible. Right now, I am creating a SqlCommand object, looping through the 100,000 rows in my array, and for each row, assigning the 40 parameters of the command object, then calling ExecuteCommand. It works, but is slow, and surely must not be the most efficient way to do this. Should I be putting all the data from the array into a DataTable, and then somehow sending the data table all at once (I don't know how to do that)? Or some other technique? Write out to a file and use bcp (seems like that wouldn't be any faster, I have not tried it). Any suggestions appreciated!