Page 1 of 1

Custom Column Headings

Posted: Thu Feb 14, 2019 11:48 am
by Support_Julie
Question:
When doing an SQL query, the data is written out to a file. How do I configure the WRITE task so that custom column headings are written to the file (not the field name)?

Answer:
If you wish to specify a column heading other than the field name, then you need to specify the column heading in the SQL statement.
You can use the SQL Wizard in MFT to build the SQL. If you select “Custom Heading”, then it lets you add whatever you want for the field heading.

Otherwise, you can modify your SQL statement by adding the AS “custom heading” syntax to the SQL for each field.
Then you can use that Output variable in a subsequent Write task (CSV below) and specify "includeHeadings="true".

For Example:
SELECT
field1 AS “Custom heading 1”,
field2 AS “Custom heading 2”
FROM
DatabaseTableName


Project example:
Code: Select all
<project name="CustomHeadingsExample" mainModule="Main" version="2.0" logLevel="verbose">
	<module name="Main">
		<sql resourceId="MyDatabaseServer" version="1.0">
			<query outputVariable="data">
				<statement>
                                      SELECT 
                                           field1 AS “Custom heading 1”,   
                                           field2 AS “Custom heading 2”
                                     FROM 
                                          DatabaseTableName
                               </statement>
		    </query>
		</sql>
		<writeCSV inputRowSetVariable="${data}" outputFile="\temp\MyFile.csv" includeHeadings="true" version="1.0" />
	</module>
</project>