SQL Server Performance

Export to Text File with header and footer

Discussion in 'SQL Server DTS-Related Questions' started by tikus, Sep 25, 2005.

  1. tikus New Member

    Hello, Can i export to text file from DTS with header and footer? What I am looking for is:


    MyFileName20050901
    Data1, Data2, Data3, Data4, Data5
    Data1, Data2, Data3, Data4, Data5
    Data1, Data2, Data3, Data4, Data5
    Data1, Data2, Data3, Data4, Data5
    MyCount0004


    I can only export the 4 data rows, however having hard time to have the first (filename) and last (row count) rows.

    THanks!
  2. simondm New Member

    Tricky one - I can't think of any easy way. A complex way would be to include an ActiveX script in your DTS after the export has happened. Using the FileSystem Object you could edit the text file. Though you may need to re-run the query in the script to get the row count. If you've got any VB Script developers handy they could probably help...

  3. tikus New Member

    I checked the VB Script. I saw that I can only append to the end. So I can probably take care of the row count, but still couldn't add the filename <img src='/community/emoticons/emotion-6.gif' alt=':(' />
  4. simondm New Member

    You could create the file first using an activeX. Then export your data (appending the file). And then append the end with another activex to update the rowcount...
  5. tikus New Member

    Actually that's what I am avoiding to do - loop through my record set to insert into the textfile one by one...

Share This Page