BTEQ export new line data

Database
Enthusiast

BTEQ export new line data

Hi,

 

I want to know the export format/option in BTEQ which can export data with new line.

 

Example to explain what is expected - Below is the sample code I am running in BTEQ

 

.export report file <filename>;

SELECT 'A
B';

.export reset;

 

Output is : AB

 

I want the output to be exported as 

A

B

 

Please suggest how I can achieve this.

  • bteq
  • export
  • export format
  • new line
  • Teradata
6 REPLIES
Senior Supporter

Re: BTEQ export new line data

Hi,

I think if you want two rows in your output you'll have to have two rows selected.

 

Something like:

.export report ...
SELECT 'A'; SELECT 'B';
.export reset;

Cheers,

Dave

Ward Analytics Ltd - information in motion
www: http://www.ward-analytics.com
Enthusiast

Re: BTEQ export new line data

I wanted to achieve this using a single select. :)

Senior Supporter

Re: BTEQ export new line data

Ok, so change the select to something like:

.export report ...
SELECT 'A'
FROM DBC.DATABASESV
WHERE DATABASENAME = USER
UNION ALL
SELECT 'B'
FROM DBC.DATABASESV
WHERE DATABASENAME = USER
;
.export reset;

Why do you need it in one select?

Cheers,

Dave

Ward Analytics Ltd - information in motion
www: http://www.ward-analytics.com
Enthusiast

Re: BTEQ export new line data

I am trying to generate a sql code spanning 100s of lines with help of metadata. I want to avoid writing a select for every line.

Senior Supporter

Re: BTEQ export new line data

Hi Abdulaziz,

 

I've done what you're trying to do many times over the years and I've always ended up writing one select for each line of generated code.

 

The only alternative that I can think of requires some non-BTEQ coding.

 

Generate the data as you originall tried to do.

Export the results to a data file.

Read that data file using a program or script as appropriate and split each line in the file on CR/LF. Write the resulting data ot a new file.

The new file now contains your SQL code.

 

Cheers,

Dave

Ward Analytics Ltd - information in motion
www: http://www.ward-analytics.com
Enthusiast

Re: BTEQ export new line data

Thanks for all your inputs Dave. I am managing currently with a solution similar to what you proposed :) .
But I still thought there should be a way which should avoid non-BTEQ scripting to achieve this.