bteq query problem.Cannot export all column to file

Database
Enthusiast

bteq query problem.Cannot export all column to file

Hi,

we trying to export SELECT * FROM TableName from db2 to flat file. By default it exports with comma as separtor and puts double quotes before and after the varchar columns. 

Now when we trying to replicate the same using bteq using report mode, we are not getting double quotes.

Please and kindly help me to figure out the problem. Is anything specific to TeraData and bteq script.

need urgent response.

2 REPLIES
Enthusiast

Re: bteq query problem.Cannot export all column to file

Try this:

bteq << EOF 

    .logon abc/def,passwd

    .EXPORT REPORT FILE=bteq_export_file

    .SET WIDTH 3000;

         SELECT col1||'|'||col2||'|'||col3  FROM db.table;

    .EXPORT RESET

    .IF ERRORCODE <> 0 THEN .quit ERRORCODE

    .quit

EOF

Enthusiast

Re: bteq query problem.Cannot export all column to file

Hi,

I have written query which is actually giving undesired result.

Output result:

23234,    45345,   "TeraData"

Expected result:

23234,45345,"TeraData"

If you see, there is space in between result set which we do not want in Textfile.

Kindly help, its on urgent basis:

Query is as follow:

bteq << ! > ./test_b.log
.SET ERROROUT STDOUT
.LOGON connectionname/username,password;
.os rm ./test_b.txt
.EXPORT REPORT FILE=./test_b.txt
.set width 65531
.set separator ','
.SET TITLEDASHES OFF;
.SET NULL AS "";
select cast(SITE_ID as varchar(10)) (title ''),
cast(ENTITY  as varchar(10)) (title ''),
cast(SITE_SEQ_NBR   as varchar(10)) (title ''),
'"'||PROP_ID||'"'(title ''),
FROM db.table;