简体   繁体   English

如何从SSIS中的SQL Server获取错误代码

[英]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;  
  } 

MSDN - Logging in the Script Task MSDN-登录脚本任务

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法从 SQL 服务器代理作业执行 SSIS Package 我收到错误“命令行参数无效” - Unable to execute SSIS Package from SQL Server Agent Job I get error " The command line parameters are invalid" 如何使用SSIS复制和覆盖SQL Server 2005中的数据库? - How Do I Copy and Overwrite a Database in SQL Server 2005 with SSIS? SQL Server如何获取带有错误代码的错误消息? - SQL Server How Can I get a error message with error code? SSIS父级不需要密码,但子级软件包却需要密码-如何使它在SQL Server代理中运行? - SSIS parent doesn't need password but child packages do - how do I get this to run in SQL server Agent? 如何停止SSIS SQL任务生成输出? - How do I stop a SSIS SQL task from generating output? 如何通过代码在Sql Server中设置默认数据库? - How do I set the default database in Sql Server from code? 为什么在SQL Server中出现此错误? 如何解决? - Why do I get this error in SQL Server? How to fix it? SQL Server中的SSIS:如何获取它来存储密码 - SSIS in SQL Server: How to get it to store password 我如何使用SQL Server从Excel中获取数据 - How do i get data from excel using sql server SQL Server:如何从历史记录表中获取数据? - SQL Server: how do I get data from a history table?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM