I found the answer in this bytes.com thread .
All you have to do is map the source columns to the destination table using SqlBulkCopyColumnMapping.
bulkCopy.ColumnMappings.Add(new SqlBulkCopyColumnMapping(0, 1));
bulkCopy.ColumnMappings.Add(new SqlBulkCopyColumnMapping(1, 2));
bulkCopy.ColumnMappings.Add(new SqlBulkCopyColumnMapping(2, 3));
bulkCopy.ColumnMappings.Add(new SqlBulkCopyColumnMapping(3, 6)); //look here, index is different
bulkCopy.ColumnMappings.Add(new SqlBulkCopyColumnMapping(4, 8)); //and again
bulkCopy.ColumnMappings.Add(new SqlBulkCopyColumnMapping(5, 9));
I also found the same solution here before finding the above, but in my case I had some fields missing from the source. The fields were in the correct order, although it referenced the actual INDEX / ORDER index. If I didn’t have the missing fields, this would work.
source
share