Basic TEradata Query is a powerful utility in Teradata for various reasons. You can write the data of a table into a file using the BTEQ export utility. You can also use it for executing conditional statements based on certain logic, for executing all kinds of DML statements.
In this post, we will see how to export a table to a file in BTEQ without a header.
LOGON teradataserver/userid,password .EXPORT DATA file = <output_path of file> .SET RECORDMODE OFF; .SET TITLEDASHES OFF; .SET SEPARATOR '|'; SELECT NAME,CITY,COUNTRY FROM CUSTDB.CUSTOMER where name='techieshouts'; .EXPORT reset; .IF ERRORCODE > 0 THEN .EXIT 1; .IF ACTIVITYCOUNT = 0 then .EXIT 2; .EXIT 0
Let us see the above script in detail
LOGON teradataserver/userid,password – This is to log into the Teradata server
.SET RECORDMODE OFF – This will suppress the column headers in the output file
.SET TITLEDASHES OFF – This will prevent the utility from printing the ‘—‘ (dashes) that will come after the column headers.
.SET SEPARATOR ‘|’ – This will create the output as ‘|’ delimited file.
We can play around by setting the values to ON and OFF. The title dashes will help the user to differentiate the column header and the actual contents. Similarly, we can set the relevant delimiter based on the data that will get exported. For example, if our data is going to have “|”, then we can use some other character as a delimiter.