2013-06-23 30 views
1

需要幫助。我試圖自動化錯誤通知發送郵件。爲此,我正在查詢sysssislog表。我在包事件處理程序「On error」上粘貼了「執行SQl任務」。出於測試目的,我故意嘗試在包含主鍵列的表中加載重複鍵(以便獲取錯誤)。減少在sysssislog中記錄多個錯誤

但是,SSIS在表中記錄3,而不是隻有一個錯誤,「違反主鍵約束」。 PFA的截圖也是如此。我如何限制工具只記錄一個錯誤,而不是多個?

包裝結構。

套餐( 「在錯誤事件處理程序」) - > 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

回答

0

的,所以所有的任務級別的錯誤「冒泡」的包裝水平,因此你看到了多個錯誤。如果您只需要1條錯誤消息,則需要區分錯誤的來源,即說明錯誤的來源。這很容易通過SourceName列(或者實際上是TaskID)完成。如果您使用即裝即用的日誌記錄,則這些列可能不可用。編寫自定義日誌腳本並不難。

1

嘗試使用以下查詢。

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

注意where子句中的子查詢?通過這樣做,我們只會選擇具有出現在PackageStart事件中的源代碼的行。 PackageStart事件始終具有頂級的源代碼,並且永遠不會有子組件的源代碼。因此,使用where子句,可以有效地過濾出所有子組件或「多個」錯誤消息。查看this article中查詢的FirstError列。

+0

謝謝你特洛伊。雖然我已經找到了類似的解決方法,但這也給了一個新的尺度。 – Akshay

+0

特洛伊,提到的查詢的結果是不正確的。我與日誌交叉驗證。使用前請檢查。 – Akshay