I am using TPT export for doing data export from TD to a file and want to include column headers to the generated file.
I would like to know if there are any attributes that is included with newer version of tpt that we can use for this., I am using TPT version 14.10
The Export (and SQL Selector) operator(s) is/are not capable of extracting out the column headers from the database.
As Steve says there are not an attribute to get file with columns header.
Many times i used one of two options:
1 - Use OS COMMAND to concatenate two files, headers file and export file. On windows "type header.txt export.txt > file.txt". On Unix "cat header.txt export.txt > file.txt"...
2 - Generate one row with columns header and Id and, make union with the data using row_number to generate id and. Finally order by id.
LOCKING ROW FOR ACCESS
FROM (-- A
SELECT 'Col1' (VARCHAR(100)) AS Col1
,'Col2' (VARCHAR(100)) AS Col2
,'Col3' (VARCHAR(100)) AS Col3
,'Col4' (VARCHAR(100)) AS Col4
,'Col5' (VARCHAR(100)) AS Col5
,'Col6' (VARCHAR(100)) AS Col6
,0 (INTEGER) AS Id
WHERE Calendar_Date = CURRENT_DATE
SELECT CAST(Col1 AS DATE FORMAT 'YYYYMMDD') (VARCHAR(100)) AS Col1
,CAST(Col2 AS INTEGER) (VARCHAR(100)) AS Col2
,CAST(Col3 AS ...) (VARCHAR(100)) AS Col3
,CAST(Col4 AS ...) (VARCHAR(100)) AS Col4
,CAST(Col5 AS ...) (VARCHAR(100)) AS Col5
,CAST(Col6 AS ...) (VARCHAR(100)) AS Col6
,CAST(Col7 AS DECIMAL(15,2)) (VARCHAR(100)) AS col7
,ROW_NUMBER() OVER(ORDER BY Col1) (INTEGER) AS Id
WHERE Col1 = ...
ORDER BY Id
If the UNION form is used, it is a good idea to use UNION ALL so that the engine is not forced to do a duplicate elimination pass over the combination of the header row and the data.