SqlBulkCopy Tutorial
(Under Construction)

This Website is under developement. It will be ready at the end of April.

SqlBulkCopy ColumnMappings


Mapping between the source and destination columns.


using (SqlBulkCopy bulkCopy = new SqlBulkCopy(connectionString))
    // SET ColumnMappings values.
    bulkCopy.ColumnMappings.Add("TheColumnInt", "TheColumnInt");
    bulkCopy.ColumnMappings.Add("TheColumnString", "TheColumnString");

    bulkCopy.DestinationTableName = "TheDestinationTable";


  • Always map column explicitly

Always map column explicitly

The default mapping under the hood of SqlBulkCopy may cause some weird issue because column are not mapped by name but by ordinal. When your table containt an identity value, you may end up by value mapped to wrong column!

See: SqlBulkCopy giving FOREIGN KEY constraint error