Flat file record count inside script task

  • Hi All,

    I have a requirement where , i need to get number of records present in the flat file . i need to achive this inside a script task . Can anyone help on this?

    Thanks

    Arun

  • Well, I find it weird that the requirement actually includes doing it in a script task because normally requirements don't care how you get it done as long as the end result is met. However... as for counting the rows in that flatfile, you'll have to move them somewhere and for each row send it to a script task where you just increment a local var for each row that passes. It's actually pretty easy.

    However, if the script is only going to count the rows, then you're better off going the easy route and putting a rowcount task between the file and its destination.

    Watch my free SQL Server Tutorials at:
    http://MidnightDBA.com
    Blog Author of:
    DBA Rant – http://www.MidnightDBA.com/DBARant

    Minion Maintenance is FREE:

  • crever , thanks for the reply.

    can u let me know the transformation where row count is possible (other than script task) , and can u also outline how to do it?

    i need this rowcount to be stored in a variable/somewhere , since i need to do some processing inside the script task based on this.

    Thanks,

    Arun

  • I have a video on how to use the rowcount.

    http://midnightdba.itbookworm.com/SSISRowCount/SSISRowCount.html

    Watch my free SQL Server Tutorials at:
    http://MidnightDBA.com
    Blog Author of:
    DBA Rant – http://www.MidnightDBA.com/DBARant

    Minion Maintenance is FREE:

  • Add a Flat File Source and Pass the rows to a row count transformation.

    This should do the job.

    Regards
    Venkat
    http://sqlblogging.blogspot.com[/url]

  • I am having problems using the count rows task.

    What I want to do is use a FOR EACH LOOP to get the name of the files. Then use a SQL Task to put the row counts in a SQL table. The files would be ragged right. The connection object doesn't like having an expression for the connection string.

    I have no problem if I hard code one file name and run it.

    Could someone help me with this?

  • To get the name of files in a directory, I suggest you review this article:

    Accessing the Windows File System from SQL Server

    Written By: Edgewood Solutions Engineers -- 6/12/2007

    http://www.mssqltips.com/tip.asp?tip=1263

    Problem

    Within my SQL Server T-SQL stored procedures and scripts I need to find out the files in a specific directory. What are some approaches to do so? I need some flexibility to capture the file names and general information for subsequent processing. What are the native SQL Server options as well as the custom options that are available?

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

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