Tuesday, February 14, 2012

DTS headers and trailers

Does anyone know how to incorporate header and trailer info in the text output from a DTS task. The SQL I'm using in the task works well when outputting to a text file on the server. However, when trying to incorporate header and trailer info the process fails. I tried doing it using SQL but the DTS transformation process is looking for fields to transform when I'm trying to output a 3 line header and 2 line trailer with the output rows in between. Has anyone done this before? Your help would be greatly asppreciated.

Here is an example of the SQL that fails:

*** Trying to get header info here ***
select 'Header'
select 'filename.txt'
select convert(char(11),getdate(),101)

*** Main SQL runs here ***
select
a.field1,
a.field2,
...

from tblA a JOIN tblB b ON b.someid = a.someid
JOIN tblC c ON c.someid = a.someid

where a.someval >= '2003'

*** Trying to get trailer info here ***
select 'Trailer'
select ''
select count(id) FROM tblAI'd bcp out three files (or echo out the header and trailer)

Then append the files to each other using dos commands...

No comments:

Post a Comment