SSIS Package was failing with error: The attempt to add a row to the data flow task buffer with error code.

Shivendoo Kumar 736 Reputation points

Hi All,
Recently I migrated SQL Server from one server to another and also upgraded from SQL 2016 to SQL 2017.

After migration and upgrade, a few SSIS packages started throwing errors like The attempt to add a row to the data flow task buffer with error code. Can't insert duplicate key in object Table XXX. Refer to the below screenshot.


When I check the source query, I can't see any duplicates. I was clueless about what is happening and then just I change my connection string from Data Source=SERVERName;Initial Catalog=DB;Provider=SQLNCLI11.1;Integrated Security=SSPI;Auto Translate=False; to Data Source=SERVERName;Initial Catalog=DB;Provider=SQLOLEDB.1;Integrated Security=SSPI;Auto Translate=False;

and issue was resolved. Basically It was native client provider causing the issue. Once I changed it to OLEDB provider for SQL. It worked without any issue.

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,851 questions
SQL Server Integration Services
SQL Server Integration Services
A Microsoft platform for building enterprise-level data integration and data transformations solutions.
2,462 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. Dilip Divakaran 76 Reputation points

    Is the Integration Services is running on the same physical computer as SQL Server after migration?

  2. Monalv-MSFT 5,896 Reputation points

    Hi @Shivendoo Kumar ,

    Can't insert duplicate key in object Table XXX.

    Please delete the duplicate data in Table XXX.

    Or please insert data into a new destination table.

    Please refer to the following link:
    I am using ssis and I am getting this error "Violation of PRIMARY KEY constraint .Cannot insert duplicate key in object . The duplicate key value is

    Best Regards,


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

  3. Shivendoo Kumar 736 Reputation points

    Again It failed and I think It has to do with Memory:

    I have tried this:

    Let see how it goes

    But Wait! There’s More!
    For those of us using SQL Server 2016 or higher, there is another property that makes this process a lot easier. Scroll back up and take another look at the screenshot of the SSIS data flow properties. There is a property there called AutoAdjustBufferSize. By default, it’s set to false, however setting it to true will instruct SSIS to ignore the value that has been set for DefaultBufferSize and it will adjust the size for you automatically. It bases its value on the DefaultBufferMaxRows setting, so be sure to set a value there. It’s a great time saver for anyone that has the option available to them. Even though it removes a lot of guess work, you still want to test it first.