Column 'ABC' does not allow DBNull.Value, but no null values in data source.

Mike McGuinness 26 Reputation points
2022-01-28T21:18:31.567+00:00

How does one troubleshoot this issue?

"Operation on target XYZ CSV failed: Failure happened on 'Sink' side. ErrorCode=SqlOperationFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=A database operation failed. Please search error to get more details.,Source=Microsoft.DataTransfer.ClientLibrary,''Type=System.InvalidOperationException,Message=Column 'ABC' does not allow DBNull.Value.,Source=System.Data,'

I have:

  • Verified that every row in the data source has a value for that column
  • Verified that "First row as header" is turned on for the source
  • I have turned on fault tolerance and still get the same error. 0/399,112 records imported
  • Have turned on logging for the copy activity and get nothing in the log except it says it picked up and processed the file.
  • Verified that all other non-null fields always have data

Source is CSV, target is Azure SQL. Same process works for many other similar files without issue.

How do you troubleshoot this with such vague error details that doesn't even point to a specific row?

Azure SQL Database
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,623 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Mike McGuinness 26 Reputation points
    2022-02-01T17:56:02.16+00:00

    FYI, I found a solution to the error bellow when importing a large CSV file. The solution was to change the source encoding from UTF-8 to US-ASCII.

    I'm still getting a timeout error on the sync, so I'll open a new question for that. The error below is now resolved:

    "Operation on target XYZ CSV failed: Failure happened on 'Sink' side. ErrorCode=SqlOperationFailed,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=A database operation failed. Please search error to get more details.,Source=Microsoft.DataTransfer.ClientLibrary,''Type=System.InvalidOperationException,Message=Column 'ABC' does not allow DBNull.Value.,Source=System.Data


  2. John Viele 0 Reputation points
    2024-08-16T14:02:03.4066667+00:00

    I am running into exact same problem as the OP. I'm testing with only 50 rows, so I generate the dataset object, then write it to a text file in a CSV format (different separator) and load it into Excel where I can easily confirm that the data all looks correct. On the particular column that is being reported, EVERY row has a valid string value. I've checked that the number of rows in the Dataset is correct in order to ensure that there's not somehow a blank/empty row.

    I really wish the error message would have reported what row the problem happened with, but this is a bogus error anyway so chasing it down directly is probably a waste of time. It just means the problem is somewhere else and SqlBulkCopy is unable to report the REAL error.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.