How to define 'TAB' as a separator in BTEQ Export

Tools & Utilities

How to define 'TAB' as a separator in BTEQ Export

I want my outfile data to be TAB delimited .

I had tried below options in my bteq export script but in the data TAB, \t such values are comming.:-

.SET SEPARATOR '^A';

.SET SEPARATOR 'TAB';

.SET SEPARATOR '\t';

.SET SEPARATOR '    ';

 

 

Tags (3)
2 REPLIES
Junior Contributor

Re: How to define 'TAB' as a separator in BTEQ Export

Better switch to TPT, either Selector or Export operator.

Teradata Employee

Re: How to define 'TAB' as a separator in BTEQ Export

The SEPARATOR command only affect report format output. So if you want to pursue using BTEQ and have it produce the tabs, you must be using REPORT format for the export. Then you can just use the TAB key to create the string in the script. But  you will also need to consider whether your last column will have any values comprised solely of spaces. If so, also using the TRIMTRAILINGSPACES OFF command so that BTEQ will not truncate the records. That requires at least BTEQ 15.00.00.02. And finally, I suggest using the "backdoor" report format export if you do not want the column titles or title dashes. To do that, you use DATA on the EXPORT command but then turn off record mode. You can find more information about such exports in BTEQ's Reference Manual.

 

Here's an example showing all the above. The instructions will create a character-based export file with column values separated by 3 tab characters when the TAB key is pressed three times to create the actual scripted SEPARATOR command string. I added a fabricated title for the third column just so you can test it out yourself to make sure you get 3 spaces after the second set of tabs.

 

.SEPARATOR '<TAB><TAB><TAB>'
.TRIMTRAILINGSPACES OFF
.EXPORT DATA file=foo
.RECORDMODE OFF
SELECT date,time,' '(TITLE 'abc');
.EXPORT RESET