减少登录sysssislog的多个错误

时间:2013-06-23 15:09:03

标签: ssis

需要帮助。我正在尝试自动化错误通知,以便在邮件程序中发送。为此,我正在查询sysssislog表。我在包事件处理程序“On error”上粘贴了“Execute SQl task”。出于测试目的,我故意尝试在包含主键列的表中加载重复键(以便获得错误)。

但是,SSIS在表中记录3,而不是只有一个错误“违反主键约束”。 PFA截图也是如此。如何限制工具只记录一个错误而不是多个???

包装结构。

Package(“On error event handler”) - > DFT - >                  Oledb来源 - > Oledb目的地

 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: "Violation of PRIMARY KEY constraint 'PK_SalesPerson_SalesPersonID'. Cannot insert duplicate key in object 'dbo.SalesPerson'.".  
  SSIS Error Code DTS_E_INDUCEDTRANSFORMFAILUREONERROR.  The "input "OLE DB Destination Input" (56)" failed because error code 0xC020907B occurred, and the error row disposition on "input "OLE DB Destination Input" (56)" specifies failure on error. An error occurred on the specified object of the specified component.  There may be error messages posted before this with more information about the failure.  
  SSIS Error Code DTS_E_PROCESSINPUTFAILED.  The ProcessInput method on component "OLE DB Destination" (43) failed with error code 0xC0209029 while processing input "OLE DB Destination Input" (56). 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.  

请指导我。非常感谢您的帮助。

由于

enter image description here

2 个答案:

答案 0 :(得分:1)

尝试使用以下查询。

    SELECT *
    FROM dbo.sysssislog
    WHERE sourceid IN (SELECT DISTINCT sourceid FROM dbo.sysssislog WHERE event = 'PackageStart')

注意where子句中的子查询?通过这样做,我们将只选择具有出现在PackageStart事件中的sourceid的行。 PackageStart事件始终具有顶级源代码,而不是子组件源代码。因此,使用where子句,您可以有效地过滤掉所有子组件或“多个”错误消息。查看this article内查询的FirstError列。

答案 1 :(得分:0)

按设计,所有任务级别错误都“冒泡”到包级别,因此您会看到多个错误。如果您只需要1个错误消息,则需要区分错误的来源,即它来自何处。这可以通过SourceName列(或实际上是TaskID)轻松完成。如果您使用开箱即用日志记录,则这些列可能不可用。编写自定义日志记录脚本并不是那么难。