[英]How do i get the error code from sql server in ssis
I have an SSIS 2008r2 package that is failing with a foreign key violation. 我有一个SSIS 2008r2软件包,由于外键冲突而失败。 I'm trying to trap the error that appears in the debug window,
我正在尝试捕获调试窗口中出现的错误,
" The INSERT statement conflicted with the FOREIGN KEY constraint "xxxx". The conflict occurred in database "xxxxxx", table "xxxxx", column 'xxxx'. "
“ INSERT语句与FOREIGN KEY约束” xxxx“发生冲突。冲突发生在数据库” xxxxxx“的表” xxxxx“的列” xxxx“中。 ”
I've tried enabling SSIS logging and also creating an event handler for the "OnError" event but the logs only provide the generic SSIS message 我尝试启用SSIS日志记录,并为“ OnError”事件创建事件处理程序,但日志仅提供通用SSIS消息
" SSIS Error Code DTS_E_PROCESSINPUTFAILED. The ProcessInput method on component "xxxxx Destination" (1458) failed with error code 0xC020844B while processing input "ADO NET Destination Input" (1461). The identified component returned an error from the Process Input 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. "
“ SSIS错误代码DTS_E_PROCESSINPUTFAILED。处理输入“ ADO NET目标输入”(1461)时,组件“ xxxxx目标”(1458)上的ProcessInput方法失败,错误代码为0xC020844B。所标识的组件从过程输入方法返回了错误。错误是特定于组件的,但错误是致命的,将导致数据流任务停止运行。在此之前可能会发布错误消息,并提供有关故障的更多信息。 ”
I would like to get the exact error to be logged (ie that this is a Foreign Key violation) instead of the DTS error. 我想获取要记录的确切错误(即,这是违反外键的错误)而不是DTS错误。 How can this be done?
如何才能做到这一点?
Try to use an OLE DB Destination instead. 尝试改用OLE DB目标。
And just for the record, if you have a script task in the SSIS you can log the error using the DTS object: 仅作记录,如果您在SSIS中有脚本任务,则可以使用DTS对象记录错误:
try
{
// your code
}
catch (Exception ex)
{
//An error occurred.
Dts.Events.FireError(0, "Script Task Example", ex.Message + "\r" + ex.StackTrace, String.Empty, 0);
Dts.TaskResult = (int)ScriptResults.Failure;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.