SSIS - How to Get Error Column Name In SSIS


We are loading data from source table to destination table. The data has to be converted to destination data types before we insert the data into Destination table. We are using Data Conversion to convert the data types of input columns. If  data is not able to convert to data type we have specified in Data Conversion Transformation we want to redirect those records. After redirecting those records, we want to log the information with Column Name which became the reason for redirection.

Solution : 

Let's create SSIS Package and see if we can get error column name without doing any custom coding.

Step 1: 
Create SSIS Package and bring data flow task to Control Flow pane. Use the OLE DB Source to extract data for Source Table. Here is definition of our Source Table with couple of records

CREATE TABLE [dbo].[SourceTable](
[Name] [varchar](100) NULL,
[SaleDate] [varchar](50) NULL

Insert into dbo.SourceTable 
('Aamir','2013-12-03 10:19:56.887'),
('Raza','Test Date')

We want to convert SaleDate to DateTime before insert into Destination table. If any value will not be able to convert then we want to redirect the row from Data Conversion Transformation.

Let's create Data Flow Task with all transformation as shown below

Redirect the Rows If truncation or Error occur

Bring Multicast and connect to the Error Output of Data Conversion. After that put Data Viewer to see the redirected rows as shown below

After executing our package we can see that the one row was converted successfully and moved to destination but one row could not converted to required data types and it is redirect to multicast. In above snapshot we can see ErrorCode, ErrorColumn (Lineage ID) Number and ErrorCode Description but we can't really tell it happened because of SaleDate Column or Name column. 

Read Package File to Get LineageIDs 

Our goal is to get the column name, to do that we have to read the package file(.dtsx) and get the Lineage IDs for columns. The lineageID can be same for different columns in different Tasks. We will also read the Task Name so each record will be unique with combination of Task Name.

Step 2: 
We will use Data Flow Task as our very first Task to read the Package definition and extract Lineage IDs, Column Names and Task Names and save these records in Cache Transformation. So we can use this data set anywhere in our package by using Lookup transformation to extract Error column Names by joining on Error Column( LineageID) and Task Name.

Let's drag data flow task to Control Flow pane and then bring Script Component. As we have to read the definition of SSIS Package. I created a variable and saved the location of same package I am working on.

Variable Name : VarPackagePath
Type : String
Value : Where ever you have saved your package.

Configure Script Component as Source and Provide the variable value for SSIS Package Path.

Go to Input and Output Columns and add columns as shown 

Hit on Edit Script and paste below script , The only part I wrote is in Red

/* Microsoft SQL Server Integration Services Script Component
*  Write scripts using Microsoft Visual C# 2008.
*  ScriptMain is the entry point class of the script.*/

using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using System.Collections;
using System.Xml;

public class ScriptMain : UserComponent

    public override void PreExecute()
          Add your code here for preprocessing or remove if not needed

    public override void PostExecute()
          Add your code here for postprocessing or remove if not needed
          You can set read/write variables here, for example:
          Variables.MyIntVar = 100

    public override void CreateNewOutputRows()

        //Declare Variables
        String TaskName;
        String ColName;
        Int32 ColLineageID;
        String ColKey;
        //Read the Package File
        XmlDocument PackageFile = new XmlDocument();

        //Create Hash Table 
        Hashtable ColKeyTable = new Hashtable();

        XmlNamespaceManager NameSpcMgr = new XmlNamespaceManager(PackageFile.NameTable);
        NameSpcMgr.AddNamespace("DTS", "");

        foreach (XmlNode childnode in PackageFile.SelectNodes("//*[@lineageId != '' and @name != '']"))

            XmlNode ExecutableNode = childnode.SelectSingleNode("ancestor::DTS:Executable[1]", NameSpcMgr);
            TaskName = ExecutableNode.SelectSingleNode("DTS:Property[@DTS:Name='ObjectName']", NameSpcMgr).InnerText;
            ColName = childnode.Attributes["name"].Value;
            ColLineageID = Convert.ToInt32(childnode.Attributes["lineageId"].Value);
            ColKey = TaskName + ColName + ColLineageID;
            if (!ColKeyTable.ContainsKey(ColKey))
                ColKeyTable.Add(ColKey, DBNull.Value);

                Output0Buffer.ColLineageID = ColLineageID;
                Output0Buffer.ColName = ColName;
                Output0Buffer.TaskName = TaskName;




Step 3: 
Bring Cache Transformation and connect Script component to it and configure Cache Transformation as shown.

Choose the Columns and Index Position

Put Data Viewer between Script component and Cache Transformation and see if LineageID,Column Name and Task Name is read correctly.

Step 4: 
As we have the Task Name, Column Name and Lineage ID , we can use this information in our actually data flow where rows are redirecting and get the column Name by joining on Task Name and Lineage ID.

Add Derived Column and Add Column "DER_DFT_Name". The value of this column will be the name of Data Flow it is in. We will be using this  in Lookup to find out Error Column Name for any record which is redirected in this data flow.

Final Output :
Connect the Matching output of Lookup to Multicast and put Data Viewer. Now we should be able to find out the Column Name which produces error for redirection of row.

Quick Summary, we have to read our Package file in First Data flow and then use that information ( Task Name, Column Name, LienageID) where ever we need that in our SSIS Package. We can create a template package with First Data Flow to read package file and save information in Cache Transformation for us to use later.

we can create a meta data table and read our all packages and save LineageIDs,Column Names and Task Names and then we do not have to read the package file inside the package. 


  1. Replies
    1. IEEE Final Year Project centers make amazing deep learning final year projects ideas for final year students Final Year Projects for CSE to training and develop their deep learning experience and talents.

      IEEE Final Year projects Project Centers in India are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation.

      corporate training in chennai corporate training in chennai

      corporate training companies in india corporate training companies in india

      corporate training companies in chennai corporate training companies in chennai

      I have read your blog its very attractive and impressive. I like it your blog. Digital Marketing Company in Chennai

  2. This comment has been removed by the author.

  3. thanks for ur valuable information,keep going touch with us

    Scaffolding dealers in chennai

  4. thanks for ur valuable information,keep going touch with us

    Scaffolding dealers in chennai


  5. You write this post very carefully I think, which is easily understand to me. Not only this, other post is also good. As a newbie this info is really helpful for me. Thanks to you.
    tally training
    Tally Training in Chennai
    Tally ERP 9 Training
    Tally Course
    tally classes
    Tally institute in Chennai
    Tally Training institute in Chennai
    Tally course in Chennai

  6. Thank you so much for providing information about SSIS and its other aspects.I think its really the best tool to provide solutions to some very complex IT problems.

    SSIS Postgresql Read

  7. I was really looking forward to using this, but unfortunately it failed on the line 'TaskName = ExecutableNode.SelectSingleNode("DTS:Property[@DTS:Name='ObjectName']", NameSpcMgr).InnerText;' with a NullReferenceException.
    Any idea why please?

  8. Máy tính để bàn là một thiết bị không thể thiếu với thời đại công nghệ thông tin như hiện nay. Cũng như hầu hết các thiết bị điện tử khác máy tính để bàn cũng gặp một vài sự cố nhất định trong quá trình sử dụng. Vậy những sự cố đó là gì và cách khắc phục ra sao. Trong thông tin bài viết này chúng tôi sẽ chia sẻ tới bạn 5 sự cố thường gặp khi sử dụng máy tính để bàn và cách khắc phục. Nếu bạn cũng đang sử dụng máy tính để bàn để làm việc. Hãy tham khảo thông tin ở bài viết dưới đây nhé


  10. AngularJS is a structural framework for dynamic web apps. It lets you use HTML as your template language and lets you extend HTML's syntax to express your application's components clearly and succinctly.
    tally training in chennai

    hadoop training in chennai

    sap training in chennai

    oracle training in chennai

    angular js training in chennai