SSIS - Log Error - Retrieve the column causing an error in SQL Server Integration Services
 
           
              29/09/2019 15:52    
              									
              
		
		      
                        
                			
              
              
                      
            
          
        In versions of SSIS before SQL Server 2016, there was no easy way in the data flow to retrieve the name of the column that caused a component to fail.
To make it works, you should follow these steps:
1 - Add a new Script Transformation (Error Details)
2 - Select only the new columns:
3 - In output add new columns:
4 - In C# script editor add this statement:
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
    Row.ErrorDescription = this.ComponentMetaData.GetErrorDescription(Row.ErrorCode);
    IDTSComponentMetaData130 componentMetaData = this.ComponentMetaData as IDTSComponentMetaData130;
    Row.ErrorColumnName = componentMetaData.GetIdentificationStringByID(Row.ErrorColumn);
}
5 - In SQL database destination, add the new columns on your log table:
alter table [stage].[LoadErrors]
add ErrorColumnName varchar(500),
ErrorDescription varchar(500)
	  alter table [stage].[LoadErrors]
	  add ErrorColumnName varchar(500),
	ErrorDescription varchar(500)  alter table [stage].[LoadErrors]
	  add ErrorColumnName varchar(500),
	ErrorDescription varchar(500)
All done!