Counting number of rows extracted

  • I am extracting a table into a text file using DTS.

    I have unique business need to send a trailer record which contains the count of records extracted.      Right now I am using this query technique to get it

    select au_id, au_lname, au_fname from authors

    Union

    select convert( char(11), count(*)), null, null from authors

     

    I have created the above query as view and use the view in the DTS to do mapping to a text file.

    Is there any other way to approach to accomplish this trailer record thing....?

    Thanks,

    Murthy

  • First off I question the need. The reading application will have to open the file and move thru the records to get the count. In that case it could have counted the records themselves.

    Otherwise you have pobably the best single solution without converting all or art to activescript.

  • Well business wants it. IT is there is to provide it.  I do not have the authority to ask why.

    Its a long story.   I need to achieve it.  I need to put a record in the each extracted file which will contain a record count. Just looking for better alternatives.

     

    Thanks,

    Murthy

     

  • Either way to add to the end you would have to close the file then reopen, might as well just keep open and do as you are doing to avoid some overhead in reopening and positioning to the end of the file for a write.

  • Do you need the trailer row to be the last row? If so, you need an ORDER BY clause and column(s) to sort by.

  • Yes, I took care of that by putting the order by clause.

     

    Thanks,

    Murthy

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

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