问题
How can I send emails with error details if there is any error in package execution? Basically how can I get error details and put them in Message of Send mail task?
回答1:
Here is the example :
Let's say i have one sql task , i want to get the email on "task failure" with the description of error .
- Now drag the email task and give precedent constraint from sql task to email task on failure .
- With in email task , give smtp connection, from, to email address , subject , message .. etc
- Create the user variables for error message
- Set the event handler for task failed or on error and create the script task with in package level .
- In script task .. we need to assign the system variables and user variables .
- Make sure the properties -- disable event handler should be false then only it will read the system variables .
Finally execute the package .. if any error occurred then you will get the email with the description .
Thanks
R
回答2:
This is what we do. We use the logging system of SSIS to log all errors to a table.
Then create an event handler at the package level. IN the event handler I send an email when something fails that contains the name of the package (which we always havea as a variable), the name of the task that failed (use variable System::SourceName for this, took me a while to find it.) and a query of the logging tables to enable the support team to quickly pull up the details (part of the body of the email, I use a variable but you don't have to).
来源:https://stackoverflow.com/questions/2460117/ssis-send-mail-for-errors