I have a flat file source connection in SSIS. I have created one flat file destination connection for error output. I have connected it with red arrow. The problem is that the error output file is created even if there is no error in the flat file source. The "Error Flat file Destination" always turns green even if no error. How to solve it . Thanks in advance
Probably, you have already found a solution. I hope this might help someone looking for a solution to this problem.
There is no in-built data flow task setting available in SSIS to do this. You can use Row Count transformation inside Data Flow task combined with File System Task on the Control Flow to achieve this.
Here is step-by-step process on how to do this. In this example, I have used a csv file named Country_State.csv containing countries and states as the source file.
Scenario:
The sample package will read the file and then write to a text file named Destination.txt. In this scenario, the error file Error.txt will be created but later deleted if there are no errors. Here, I have the files stored in the path c:\temp\
Step by step flow:
Source connection should point to the csv file path c:\temp\Country_State.csv. Refer screenshot #2 for the contents of this file.Destination connection should point to a text file named c:\temp\Destination.txt. Error connection should point to a text file named c:\temp\Error.txt.ErrorCount.Data Flow Task and then place a File System Task.Expression and paste the value @ErrorCount == 0 in the Expression textbox.Source connection manager.Destination connection manager.Row Count transformation on the data flow tab and configure it to use the Variable User:ErrorCount.Error connection manager.Error connection. Delete file and set the SourceConnection to Error. Refer screenshot #5.C:\temp before package execution are shown in screenshot #6.C:\temp after package execution are shown in screenshot #9.Source connection manager to integer (even though state names are strings) so that the data flow task redirects to the Error output.C:\temp after Scenario 2 package execution are shown in screenshot #12. Notice that the file Destination.txt is present even though there were no successful rows. This is because the example deletes only the Error file if it is empty.Similar logic can be used to delete a empty Destination file.
Hope that helps.
Screenshot #1:

Screenshot #2:

Screenshot #3:

Screenshot #4:

Screenshot #5:

Screenshot #6:

Screenshot #7:

Screenshot #8:

Screenshot #9:

Screenshot #10:

Screenshot #11:

Screenshot #12:

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With