BTEQ - Parametrize output File

Tools & Utilities

BTEQ - Parametrize output File

Hi all,

I need to export data from Teradata to text files (Windows).

The first one is a .BAT file that only call the BTEQ application:

1 - bteq < file.sql

The second one exports the data:

2 -

.logon myhost/myuser,myuser


.EXPORT FILE=out.txt

select col1, col2

from table1;

.EXPORT RESET

.QUIT

Now I need to send a variable from .BAT file to .sql file giving the file name where I want to export data, for example, if the information is related to countries, I want to generate a file by country:

1 - 

bteq < file.sql  Canada

bteq < file.sql  USA

bteq < file.sql  Colombia

2 - 


.logon myhost/myuser,myuser


.EXPORT FILE=%Country%.txt

select col1, col2

from table1

where country='%1%';

.EXPORT RESET

.QUIT


How can I do this?

Thanks in advance.

Regards.

2 REPLIES
Teradata Employee

Re: BTEQ - Parametrize output File

You can't do that using TTUs. Yet you can achieve the same results using a little coding in any language .... to give an interface to get variables and replace & execute the scripts.

Re: BTEQ - Parametrize output File

Have a look for this Python package - https://github.com/zhongdai/wbteq