Need to include column heading in Teradata Bteq script

Tools & Utilities

Need to include column heading in Teradata Bteq script

Hi ,

This is my teradata teg script and need to include column heading.

.SET SESSION TRANSACTION ANSI

.BEGIN EXPORT SESSIONS 20;

.RUN    FILE=${ETL_LOGON}

.EXPORT RESET;

.EXPORT DATA FILE = /pmretl/data001/SessLogs/RXDM/market_data.csv

/*Setting format of output file*/

.SET RECORDMODE OFF

.SET WIDTH 65531;

.RETLIMIT 2147483407,2048;

.SET SEPARATOR ",";

.SET NULL AS "";

.SET TITLEDASHES OFF;

.SHOW CONTROLS;

SELECT

VNDR_SRC_MRKT_ID||','||

trim(DATA_SRC_ID)||',"'||

trim(FILE_NM)||'",'||trim(SRC_CD)||','||trim(CAST(MSTR_PROD_ID AS integer))||',"'||trim(MRKT_NM)||'",'||trim(CRTN_DT)||','||LAST_UPDT_DT

(title '')

FROM GHHUSDW_PMR_STAGE_ETL.SRC_MRKT_XREF

where data_src_id =8;

.EXPORT RESET

.QUIT

6 REPLIES
Junior Contributor

Re: Need to include column heading in Teradata Bteq script

This is not a working BTEQ script, there's no BEGIN EXPORT in BTEQ.

Simply write a select returning a concatenated list of all column name before you run your actual select:

SELECT
'VNDR_SRC_MRKT_ID'||','||
'DATA_SRC_ID'||','||
...
(title '');

Dieter

Enthusiast

Re: Need to include column heading in Teradata Bteq script

Hi,

you can use thus:

.SET TITLEDASHES ON

.EXPORT REPORT FILE= /pmretl/data001/SessLogs/RXDM/market_data.csv

SELECT VNDR_SRC_MRKT_ID,DATA_SRC_ID from GHHUSDW_PMR_STAGE_ETL.SRC_MRKT_XREF .........

.EXPORT RESET

Cheers,

Raja

Re: Need to include column heading in Teradata Bteq script

sorry  dieter,

I forget to include the below steps in the forum. Now i can get the column heading.thanks for the help!!!!

.SET SESSION TRANSACTION ANSI

.BEGIN EXPORT SESSIONS 20;

.RUN    FILE=${ETL_LOGON}

.EXPORT RESET;

Re: Need to include column heading in Teradata Bteq script

Hi All,

I am getting a Deadlock when I run multiple sessions in parallel which insert into a table in Teradata. Please find the attached below error.

  odbc teradata driver error  teradata database transaction ABORTED due to deadloack.unable to get catalog string

I rerun the session one by one (sequential order) and the session is completed successfully.

pls help me how to fix this one

Re: Need to include column heading in Teradata Bteq script

how i can export file like..

.SET TITLEDASHES ON

.EXPORT REPORT FILE= /pmretl/data001/SessLogs/RXDM/market_data.csv

SELECT VNDR_SRC_MRKT_ID as VSND,DATA_SRC_ID as DSI  from GHHUSDW_PMR_STAGE_ETL.SRC_MRKT_XREF .........

.EXPORT RESET

so acn i write VNDR_SRC_MRKT_ID as VSND,DATA_SRC_ID as DSI

like that?

Teradata Employee

Re: Need to include column heading in Teradata Bteq script

Manish, please post your BTEQ question to the Tools Forum. thanks.