SSIS 2016 ROW counts to a Flat File destination

  • Hi, I have 3 flat file sources. Now I want to count the number of records in each flat file and I want to write the counts to a flat file in the below output.

    FileName  Count

    can anyone suggest me step by step on how exactly I achieve this ?

    Many Thanks

     

     

  • You want only the counts, not the data in the files?

    Use a Script Task to get the counts

    var rowCount = File.ReadLines(file).Count();

    and write that out to a file of your choice ... all done using a Script Task.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • yes ONLY the counts and not the data but the csv output file should contain the below fields.

     

    FileName  Count

     

    Thank you

  • Phil, can you please give me the exact code the for the script task ?

     

     

  • BIsweet wrote:

    Phil, can you please give me the exact code the for the script task ?

    I could, but that would mean I was doing your job for you.

    How about you at least attempt this & come back with any questions you encounter along the way?

    Otherwise, I will provide you with a quotation for my services on a consultancy basis.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • Hi Phil, do you think its better to use Row count transformation and take the counts into variables first ?

     

    Thanks

  • BIsweet wrote:

    Hi Phil, do you think its better to use Row count transformation and take the counts into variables first ?

    Thanks

    Getting row counts using that transformation requires reading every row of every file. It will work, but it will be slower that using the scripted solution I suggested.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply