The difficulty of extracting the error column name in an SSIS data flow is widely recognized. To meet the requirement of minimizing scripting transforms/components, I cannot use a complex scripting solution to identify error columns in the dataflow. However, by utilizing two lines of C# that are well documented, I can obtain the Error Column description, which is the value shown in the Data Viewer—a string with the column name at the end, such as:
"OLEDB_DEST - Load Raw Dimension.Inputs[OLE DB Destination Input].Columns[ProductID]".
Below is my code in the ProcessInputRow method
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
// Get the error description
Row.ErrorDescription = this.ComponentMetaData.GetErrorDescription(Row.ErrorCode);
// Get the error column name
IDTSComponentMetaData130 componentMetaData = this.ComponentMetaData as IDTSComponentMetaData130;
Row.ErrorColumnName = componentMetaData.GetIdentificationStringByID(Row.ErrorColumn);
}
I am seeking a method to use the Derived Column transformation to consistently extract the string between the last two brackets, which is the column name. Any help is appreciated.
Thank you!
I've tried using SUBSTRING AND FINDSTRING but without success.
You can add a couple of more lines to the script that you are using to extract the ErrorColumn - Description
which will be simpler than using a derived column:
IDTSComponentMetaData130 componentMetaData130 = this.ComponentMetaData as IDTSComponentMetaData130;
string errorColumn = componentMetaData130.GetIdentificationStringByID(Row.ErrorColumn);
int start = errorColumn.LastIndexOf('[') + 1;
int end = errorColumn.LastIndexOf(']');
Row.ErrorColumnName = errorColumn.Substring(start, end - start);
EDIT: Adding screenshots for clarification:
ErrorColumn
so we can get the source id.ErrorColumnName
4.The ProcessInputRow
method should look like this: