I am performing a SQLBulkCopy which is working fine except I would like to get some info on SqlBulkCopyColumnMapping. I have 2 columns that are being mapped out of 20, the other 18 columns match up and don't require SqlBulkCopyColumnMapping to be used. So after mapping my 2 columns and running my script I noticed that the only data that was copied between tables was the 2 columns that were mapped, not the other 18. Does this mean I have to map ALL columns so that all of the data can be copied or is there a way to tell SQLBulkCopy that the rest of the columns already match up and just copy them?
I am working in ASP.Net/VB and below is a sampling of the code I have
Using bulkCopy As SqlBulkCopy = New SqlBulkCopy(destinationConnection) bulkCopy.DestinationTableName = "dbo.WebProxyLog" Dim mapTime1 As New SqlBulkCopyColumnMapping("logTime", "logDate") bulkCopy.ColumnMappings.Add(mapTime1) Dim mapTime2 As New SqlBulkCopyColumnMapping("logTime", "logTime") bulkCopy.ColumnMappings.Add(mapTime2) bulkCopy.BulkCopyTimeout = 2000 Try bulkCopy.WriteToServer(reader) Catch ex As Exception Console.WriteLine(ex.Message) Finally reader.Close() End Try End Using