The given columnMapping does not match up with any column in the source or destination

The SqlBulkCopy object is good, but probably super twitchy. The fact that it is case sensitive to columnames to me is a sign of likely low code quality, and the error that gives this blog entry its title is another.

Sometimes bulk copy will import a table from text without explicitly setting the columns. Sometimes you have to explicitly set the columns and poof! it works. It may have to do with white space or case sensitivity in the columns, or it may have to do with drivers making inaccurate counts of fields.

SqlBulkCopy bcp = new SqlBulkCopy(
“Server=.;persist security info=True;initial catalog=target;Integrated Security=SSPI”,
SqlBulkCopyOptions.KeepIdentity & SqlBulkCopyOptions.KeepNulls);

bcp.BatchSize = 50000;

for (int i=0;i {
string name = reader.GetName(i).Trim().ToLower();

for (int i = 0; i < bcp.ColumnMappings.Count-1; i++)
bcp.DestinationTableName = file.Name.Split(‘.’)[0];



NOTE: Even explicitly listing the columns often is not enough. I eventually gave up and used alternate techniques. The command is poorly documented with respect to what text formats are acceptable for BIT, DATETIME, IMAGE when doing heterogeneous bulkcopy. Until MSDN documents it, this otherwise fantastic tool is only reliable for copying from SQL to SQL with identical schemas and probably identical version and patch levels.

2 thoughts on “The given columnMapping does not match up with any column in the source or destination

  1. What I found is that when bulk copying the number of fields or colums in the input and the table must be there. The table can contain more columns but it has to at least have the same number of columns as the input.

  2. Hi,
    I also face the same proble.I notice that this type of error will occurs when the Source Column name and Destination Column name spelling not same.
    So you have to check and write the same column names in Tables also