SSIS 2016 ROW counts to a Flat File destination

  • BIsweet

    SSC Veteran

    Points: 283

    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

     

     

  • Phil Parkin

    SSC Guru

    Points: 243772

    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.

    If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

  • BIsweet

    SSC Veteran

    Points: 283

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

     

    FileName  Count

     

    Thank you

  • BIsweet

    SSC Veteran

    Points: 283

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

     

     

  • Phil Parkin

    SSC Guru

    Points: 243772

    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.

    If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

  • BIsweet

    SSC Veteran

    Points: 283

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

     

    Thanks

  • Phil Parkin

    SSC Guru

    Points: 243772

    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.

    If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

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

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