Search code examples
sql-serverssisssrs-2008ssms

SQL Server : Statement Conflict


I'm working with SCRUBS and I'm trying to run a job on SSMS but I'm getting this error:

Started:  3:41:55 PM  
Error: 2015-07-31 15:41:58.03     
Code: 0xC0202009     
Source: Reports Write new Reports [135]     
Description: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has   occurred. 
Error code: 0x80004005.  
An OLE DB record is available.  
Source: "Microsoft SQL Server Native Client 10.0"  
Hresult: 0x80004005  
Description: "The statement has been terminated.".  
An OLE DB record is available.  
Source: "Microsoft SQL Server Native Client 10.0"  
Hresult: 0x80004005  
Description: "The INSERT statement conflicted with the FOREIGN KEY   constraint "FK__Reports__ReportT__2D27B809". The conflict occurred in database  "SummitCloud_SCRUBS", table "dbo.ReportTypes", column 'ReportType'.".  
End Error

Error: 2015-07-31 15:41:58.03     
Code: 0xC0047022     
Source: Reports SSIS.Pipeline     
Description: SSIS Error Code DTS_E_PROCESSINPUTFAILED.  The ProcessInput method on component "Write new Reports" (135) failed with error code 0xC0202009 while processing input "OLE DB Destination Input" (146). The identified component returned an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running.  There may be error messages posted before this with more information about the failure.  
End Error  

DTExec: The package execution returned DTSER_FAILURE (1).

I've looked into the .dtsx file but I can't see anything wrong with the design. The columns [ReportTypes].ReportType and [Reports].ReportType also have the same type. So I'm not sure what the what problem is.

Does anyone know why I'm getting this error, please?

Thanks


Solution

  • Error is specifically

    The INSERT statement conflicted with the FOREIGN KEY constraint "FK__Reports__ReportT__2D27B809". The conflict occurred in database "SummitCloud_SCRUBS", table "dbo.ReportTypes", column 'ReportType'.".

    which means that you are trying to insert something in the FK column ReportType which does not exist as PK in the primary key table

    How to correct:

    1. Open database SummitCloud_SCRUBS in SQL Server Management Studio
    2. Open the table dbo.ReportTypes in design view.
    3. See relationships on this table, and find one named FK__Reports__ReportT__2D27B809 and see what is the table for the primary key.
    4. Check that table for valid PK values which can be inserted as FK in the table.
    5. Try to check what are you trying to put in the column.

    Hack:

    Remove the FK relationship and see what gets in the table.