Question about using sqlbulk copy column mapping

  • I have an extract which the user will upload and i am trying to use the sqlbulkcopy.columnmapping for it and i have a question..

    For eg.. if my extract has columns a,b,c,d and another extract has column a,b and d but no c...

    When i import that information to database using sqlbulkcopy...

    i do this

    Using BulkCopy As SqlBulkCopy = New SqlBulkCopy(sqlConnectionString)

    BulkCopy.DestinationTableName = "PartDBF"

    BulkCopy.ColumnMappings.Add("a", "a")

    BulkCopy.ColumnMappings.Add("b", "b")

    BulkCopy.ColumnMappings.Add("c", "c")

    BulkCopy.ColumnMappings.Add("D", "D")

    BulkCopy.WriteToServer(dr)

    End Using If in any of my extract suppose a column doesnt exists will sql server still throw me a invalid column mapping error

    any help will be appreicated.

    thanks

    Karen

Viewing post 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply