Trying to insert data using SqlBulkCopy, and I get this error:
Received an invalid column length from the bcp client for colid 6
They recommend one of two things:
- Increase varchar size in DB (to accommodate larger strings)
- Manually truncate the strings in DataTable (with my own code) before uploading (to make strings appropriate size)
But I'm happy for "implicit truncating" to occur... (i.e. the DB insertion or the SqlBulkCopy itself cuts the users' supplied value down to appropriate size)
Questions:
- Is it possible to use SqlBulkCopy and get "implicit truncating" behavior like when setting SqlCommand "
SET ANSI_WARNINGS OFF
", so that "When OFF, data is truncated to the size of the column and the statement succeeds" - Can I change a setting on my DB to allow "implicit truncating"?
- Is there an alternative to SqlBulkCopy which will allow this?
- Or maybe I should just use one of the recommended approaches (but I feel like manually truncating the data in the DataTable on my own would have a performance penalty?)