SSIS Event Handler - How do I get the entire error message?

0

I've set up a data flow task with a source component (ODBC to Salesforce) that writes rowcounts and any raised error messages to a table.

I've created an OnError event handler that writes the message from System::ErrorDescription to a variable, and then that variable is written to the table.

My problem is that System::ErrorDescription doesn't have the interesting error message, but the summary. These are the messages being generated in the Progress tab:

  • [SRC - Extract Account [6]] Error: System.Data.Odbc.OdbcException (0x80131937): ERROR [HY000] INVALID_LOGIN: Invalid username, password, security token; or user locked out.etc, etc,etc
  • [SSIS.Pipeline] Error: SRC - Extract Account failed the pre-execute phase and returned error code 0x80131937.

System::ErrorDescription only has the [SSIS.Pipeline] error ("SRC - Extract Account failed the pre-execute phase and returned error code 0x80131937"). How do I return the more detailed [SRC - Extract Account [6]] message?

Thanks, Jason

ssis
asked on Stack Overflow Aug 22, 2017 by Jason Campbell

2 Answers

0

You could also just query your SSISDB to get the error.

Use event_name to find your error

Try this:

/*  
:: PURPOSE
Show the Information/Warning/Error messages found in the log for a specific execution
:: NOTES
The first resultset is the log, the second one shows the performance
:: INFO
Author: Davide Mauri
Version: 1.1
:: VERSION INFO
1.0: 
First Version
1.1:
Added filter option on Message Source
Correctly handled the "NULL" filter on ExecutionId
*/
USE SSISDB
GO
/*
Configuration
*/
-- Filter data by execution id (use NULL for no filter)
DECLARE @executionIdFilter BIGINT = NULL;
-- Show only Child Packages or everyhing
DECLARE @showOnlyChildPackages BIT = 0;
-- Show only message from a specific Message Source
DECLARE @messageSourceName NVARCHAR(MAX)= '%'
/*
Implementation
*/
/*
Log Info
*/
SELECT * FROM catalog.event_messages em 
WHERE ((em.operation_id = @executionIdFilter) OR @executionIdFilter IS NULL) 
AND (em.event_name IN ('OnInformation', 'OnError', 'OnWarning'))
AND (package_path LIKE CASE WHEN @showOnlyChildPackages = 1 THEN '\Package' ELSE '%' END)
AND (em.message_source_name like @messageSourceName)
ORDER BY em.event_message_id;
/*
Performance Breakdown
*/
IF (OBJECT_ID('tempdb..#t') IS NOT NULL) DROP TABLE #t;
WITH 
ctePRE AS 
(
SELECT * FROM catalog.event_messages em 
WHERE em.event_name IN ('OnPreExecute')
AND ((em.operation_id = @executionIdFilter) OR @executionIdFilter IS NULL)
AND (em.message_source_name like @messageSourceName)
), 
ctePOST AS 
(
SELECT * FROM catalog.event_messages em 
WHERE em.event_name IN ('OnPostExecute')
AND ((em.operation_id = @executionIdFilter) OR @executionIdFilter IS NULL)
AND (em.message_source_name like @messageSourceName)
)
SELECT
b.operation_id,
from_event_message_id = b.event_message_id,
to_event_message_id = e.event_message_id,
b.package_path,
b.execution_path,
b.message_source_name,
pre_message_time = b.message_time,
post_message_time = e.message_time,
elapsed_time_min = DATEDIFF(mi, b.message_time, COALESCE(e.message_time, SYSDATETIMEOFFSET()))
INTO
#t
FROM
ctePRE b
LEFT OUTER JOIN
ctePOST e ON b.operation_id = e.operation_id AND b.package_name = e.package_name AND b.message_source_id = e.message_source_id AND b.[execution_path] = e.[execution_path]
INNER JOIN
[catalog].executions e2 ON b.operation_id = e2.execution_id
WHERE
e2.status IN (2,7)
OPTION
(RECOMPILE)
;
answered on Stack Overflow Aug 22, 2017 by SqlKindaGuy
0

I know the question is old, but I had this problem today. Each error message line fires OnError event. So to capture all error lines concatenate the value of yours variable. Something like that: Dts.Variables["MyErrorVar"].Value = Dts.Variables["MyErrorVar"].Value + Environment.NewLine + Dts.Variables["System::ErrorDescription"].Value.ToString()

answered on Stack Overflow Dec 5, 2019 by Samada

User contributions licensed under CC BY-SA 3.0