Special Characters in Teradata Bteq export

622 views Asked by At

I have a Teradata bteq script exporting table definitions by running show table from a linux server. My problem is the script outputs the ddl into a file with new lines (^M) in each line and random characters at the beginning of the script. I can post process the file with linux commands to remove ^M. But since the characters at the beginning of the files are random it is difficult to code to remove them.

Script below:

#!/bin/sh
#########################################
DATADIR=[directoryname]
bteq <<EOI
.logmech LDAP
.LOGON server/user/pass;

.EXPORT DATA FILE=$DATADIR/script.sql
SHOW TABLE mydatabasename.mytablename;
.EXPORT RESET;
.IF ERRORCODE <> 0 THEN .EXIT ERRORCODE;

.LOGOFF
.EXIT
EOI
#########################################

First line of the export looks like below:

a^E_^ECREATE MULTISET TABLE mydatabasename.mytablename ,FALLBACK ,^M 

Is there something I can do in the script to avoid getting the special characters?

0

There are 0 answers