Export to Text File with header and footer | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Export to Text File with header and footer

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!
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…
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=’:(‘ />
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…
Actually that’s what I am avoiding to do – loop through my record set to insert into the textfile one by one…
]]>