Data Copy Fails When Upserting NULL Into Primary Key Field

Shaun Bailey 86 Reputation points
2022-05-02T16:13:00.287+00:00

First, here is the error I am receiving:

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.Data.SqlClient.SqlException,Message=Cannot insert the value NULL into column 'Id', table 'ThisIsMyTable.dbo.InterimTable_483044d4-1d64-48af-a5a6-4dbefeee6d9c'; column does not allow nulls. INSERT fails.  
The statement has been terminated.,Source=.Net SqlClient Data Provider,SqlErrorNumber=515,Class=16,ErrorCode=-2146232060,State=2,Errors=[{Class=16,Number=515,State=2,Message=Cannot insert the value NULL into column 'Id', table 'ThisIsMyTable.dbo.InterimTable_483044d4-1d64-48af-a5a6-4dbefeee6d9c'; column does not allow nulls. INSERT fails.,},{Class=0,Number=3621,State=0,Message=The statement has been terminated.,},],'  

When using an Insert, the table loads just fine without any errors. However, when I try to UPSERT, I get the error above. Any ideas? I need to lookup on LoanNumber and upsert based on that column.

198248-config1.png

I have a Primary Key column named 'Id' setup on my table but no other keys.

198275-config2.png

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

Accepted answer
  1. ShaikMaheer-MSFT 38,546 Reputation points Microsoft Employee Moderator
    2022-05-04T06:21:20.723+00:00

    Hi @Shaun Bailey ,

    Thank you for posting query in Microsoft Q&A Platform.

    From error messages, it's saying that system is trying to insert null value in to id column. And as shown below screenshot id column does not allow nulls. Hence ending up with this error.

    198677-image.png

    Kindly cross check your data and see if any nulls are getting inserted and try to avoid them to insert.

    Between, what is your source and sink data systems?

    Hope this helps. Please let us know how it goes. Thank you.

    0 comments No comments

0 additional answers

Sort by: Most helpful

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.