SQL Server:语句冲突

时间:2015-07-31 16:28:03

标签: sql-server ssis ssrs-2008 ssms

我正在与SCRUBS合作,我正在尝试在SSMS上工作,但我收到了这个错误:

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).

我查看了.dtsx文件,但我看不出设计有什么问题。列[ReportTypes].ReportType[Reports].ReportType也具有相同的类型。所以我不确定是什么问题。

有人知道我为什么会收到这个错误吗?

由于

2 个答案:

答案 0 :(得分:2)

错误具体是

  

INSERT语句与FOREIGN KEY约束冲突" FK__Reports__ReportT__2D27B809"。冲突发生在数据库" SummitCloud_SCRUBS",table" dbo.ReportTypes",column' ReportType'。"。

这意味着您正在尝试在FK列ReportType中插入一些在主键表中不存在PK的内容

如何纠正:

  1. 在SQL Server Management Studio中打开数据库SummitCloud_SCRUBS
  2. 在设计视图中打开表格dbo.ReportTypes
  3. 查看此表上的关系,找到一个名为FK__Reports__ReportT__2D27B809的表,并查看主键的表。
  4. 检查该表是否有有效的PK值,可以在表格中作为FK插入。
  5. 尝试检查您要在列中添加的内容。
  6. 哈克:

    删除FK关系并查看表中的内容。

答案 1 :(得分:2)

错误与FOREIGN KEY约束有关,而与数据类型无关。看起来你试图放入该表的任何值都不是表ReportTypes中的有效PK