我正在将行从平面文件源重定向到平面文件目标.重定向行中的默认元数据是:
我在输出平面文件中得到的是源行(不错)和错误代码(不好,例如-1071628249)和错误列(不好,因为它是列的内部ID).
如何转换行以输出错误消息(例如"数据被截断.")和平面文件源中定义的列名?
换句话说,而不是...,-1071607675,10
我想看到:
...,The data was truncated,Firstname
或者(如果以前不可能);
...,DTS_E_FLATFILESOURCEADAPTERSTATIC_TRUNCATED,Firstname
.
Per*_*uel 14
错误消息列表位于以下位置:MSDN,Integration Services错误和消息参考 http://msdn.microsoft.com/en-us/library/ms345164%28v=sql.100%29.aspx
和列数编号可在SSIS的数据流任务中找到:选择任务组件生成错误,高级编辑,"输入和输出属性"选项卡中,外部列的属性.
Ber*_*ann 13
可以使用脚本组件实现部分问题(添加错误描述).使用脚本组件增强错误输出中对此进行了描述.
似乎Dougbert博客有一个添加列名的解决方案,但它远非简单.我很惊讶这在SSIS中很难做到; 您认为知道源和列的名称是一个基本需求.
小智 6
可以使用脚本组件作为转换来实现,将错误输出重定向到脚本组件并按照步骤实现您要查找的内容。
(1) 打开脚本组件,
输入列选择
输入和输出添加输出列
(2) 编辑脚本
粘贴以下代码
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
#endregion
/// <summary>
/// This is the class to which to add your code. Do not change the name, attributes, or parent
/// of this class.
/// </summary>
[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
var component130 = this.ComponentMetaData as IDTSComponentMetaData130;
if (component130 != null)
{
Row.ErrorDescription = component130.GetErrorDescription(Row.ErrorCode);
Row.ErrorColumnDescription = component130.GetIdentificationStringByID(Row.ErrorColumn);
}
}
Run Code Online (Sandbox Code Playgroud)