Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6051141
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:46:08+00:00 2026-05-23T07:46:08+00:00

We have a script task that processes a flatflat, inserts data into the database,

  • 0

We have a script task that processes a flatflat, inserts data into the database, then records any duplicates (via a stored proccedure) into a SQL table, which then passes it to a work flow task that looks up that table & writes all data into a file then trucates the table.

The problem is even when there is 0 errors recorded, it always writes an log flatfile.

Is there a way to write a flatfile where there is > 0 records in the duplicate log table?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:46:08+00:00Added an answer on May 23, 2026 at 7:46 am

    Here is a possible option that might give you an idea of getting rid of Error file that have no records.

    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:

    1. On the connection manager section, create three flat file connections namely Source, Destination and Error. Refer screenshot #1.
    2. Source connection should point to the csv file path c:\temp\Country_State.csv. Refer screenshot #2 for the contents of this file.
    3. Destination connection should point to a text file named c:\temp\Destination.txt.
    4. Error connection should point to a text file named c:\temp\Error.txt.
    5. Create a variable of data type Int32 named ErrorCount.
    6. On the Control Flow tab, place a Data Flow Task and then place a File System Task.
    7. Connect the Data Flow Task to File System Task.
    8. Right click on the connector between Data Flow Task and File System Task.
    9. On the Precedence Constraint Editor, change the Evaluation operation to Expression and paste the value @ErrorCount == 0 in the Expression textbox.
    10. Your control flow should look like as shown in screenshot #3.
    11. Inside the data flow task on the data flow tab, drag and drop a Flat File Source and configure it to use Source connection manager.
    12. Place a Flat File Destination and configure it to use Destination connection manager.
    13. Connect the green output arrow from the Flat File Source to the Flat File Destination.
    14. Place a Row Count transformation on the data flow tab and configure it to use the Variable User:ErrorCount.
    15. Connect the red output arrow from the Flat File Source to the Row Count transformation.
    16. Place a Flat File Destination and configure it to use Error connection manager.
    17. Connect the output from Row Count to the Flat File Destination using Error connection.
    18. Your data flow task should look like as shown in screenshot #4.
    19. On the Control Flow tab, double-click on the File System Task.
    20. On the File System Task Editor, set the Operation to Delete file and set the SourceConnection to Error. Refer screenshot #5.
    21. Contents of the folder path C:\temp before package execution are shown in screenshot #6.
    22. Data flow tab execution is shown in screenshot #7.
    23. Control flow execution is shown in screenshot #8.
    24. Contents of the folder path C:\temp after package execution are shown in screenshot #9.
    25. To show this actually works, I changed the second column on the Source connection manager to integer (even though state names are strings) so that the data flow task redirects to the Error output.
    26. Scenario 2 Data flow tab execution is shown in screenshot #10.
    27. Scenario 2 Control flow execution is shown in screenshot #11. Notice that the File System Task is not executed because the error file is not empty.
    28. Contents of the folder path 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:

    1

    Screenshot #2:

    2

    Screenshot #3:

    3

    Screenshot #4:

    4

    Screenshot #5:

    5

    Screenshot #6:

    6

    Screenshot #7:

    7

    Screenshot #8:

    8

    Screenshot #9:

    9

    Screenshot #10:

    10

    Screenshot #11:

    11

    Screenshot #12:

    12

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Ant script that performs a copy operation using the 'copy' task
I have a PHP script that grabs data from an external service and saves
I have an SSIS 2008 package that reads data from an Access database (OLEDB
I have a script that parses the filenames of TV episodes (show.name.s01e02.avi for example),
I have a script that retrieves objects from a remote server through an Ajax
I have a script that checks responses from HTTP servers using the PEAR HTTP
I have a script that takes a table name and generates a control file
I have a script for OS X 10.5 that focuses the Search box in
I have a script that renders graphs in gnuplot. The graphs all end up
I have a script that works fine on my test server (using IIS6). The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.