CSV export using Teradata BTEQ cuts off column and inserts dashed line

58 Views Asked by At

I am recently trying to learn how to use Teradata's BTEQ utility. For starters, I would like to select a few rows and export them to a CSV. This is my code:

.LOGMECH KRB5;
.LOGON server/user;

.EXPORT FILE filepath\bteq_export_test.csv;
.SET RECORDMODE OFF;
.SET SEPARATOR ',';

SELECT TOP 3 column1, column2, column3 FROM mydb.mytable;

.EXPORT RESET;

.LOGOFF;

I execute this BTEQ script from the Windows command line:

bteq < my_bteq_script.btq

This gives me a CSV file that looks something like this:

column1, column2
------- -------------------------------------------------------------------
2013    ,5202225914
2014    ,5200770382
2017    ,5200790116

The horizontal line inserted by BTEQ is undesirable and column 3 simply does not show up. Column2 has data type VARCHAR(100), so it makes sense that it takes up so much space in the CSV output. But that doesn't mean that the other column, column3, should be cut off.

Thus, I have two questions:

  1. Is there a row width limit in BTEQ that I need to modify and if yes, how do I do so?
  2. Why is the dashed line added and how can I get rid of it?

Thanks for any tips you might have!

EDIT: My desired output would look something like this:

column1,column2,column3
2013,5202225914,sometext
2014,5200770382,someothertext
2017,5200790116,yetsomeothertext
1

There are 1 best solutions below

0
On

As mentioned by the commenters, the solution is adding these two lines to the script:

.SET TITLEDASHES OFF 
.SET WIDTH 10000

The WIDTH can be any number, as long as it's high enough. Related Teradata documentation pages can be found here:

https://docs.teradata.com/r/Basic-Teradata-Query-Reference/February-2022/BTEQ-Commands/BTEQ-Command-Descriptions/TITLEDASHES

https://docs.teradata.com/r/Basic-Teradata-Query-Reference/February-2022/BTEQ-Commands/BTEQ-Command-Descriptions/WIDTH