All Forums Tools
ineedhelp 1 post Joined 11/11
26 Jan 2012
Passing Parameter to BTEQ

How can I pass a parameter to BTEQ during run time (In Windows)?


I have 2 DB's like QA_TEST & DEV_TEST

I need to test the BTEQ script with both QA and DEV data. So instead of creating 2 BTEQ's, is there a way i can pass QA_TEST DB for my QA testing and DEV_TEST DB for my dev testing?

hans-peter 7 posts Joined 11/04
31 Jan 2012

...have you already thought about a simple replacement of a unique text pattern :

In a unix environment the following  is working: (i'm not too familiar with current windows scripting possibilities, but a similar approch should be possible there, too ?!).

You specify the DB in the BTEQ-Script using a unique textstring e.g. '&TD_DB' (the $-sign is not absolutely necessary as long as the textstring does only appear at positions where it shall be replaced. we use it to emphasize that there is a parameter that has to be replaced at runtime). Then you can call the BTEQ Script for QA-Testing as follows:

> sed 's/\&TD_DB/QA_TEST/g' < test.btq | bteq

13 Feb 2012

If you are using UNIX to run the BTEQ u can try parm file..

create a param  file and  assign value for your DB ex:userfolder/param

inside that create a variable that your going to use in BTEQ and assign it to respective replacement value



in the script point to that param location like

. userfolder/param

Inside the bteq use $TD_DB in the query.while running it will b automatically replaced by the param value

yamyro 3 posts Joined 04/15
15 Apr 2015

Hello, I was searching a solution on internet for this topic, one solution that you can try is to create and pass the parameters bye a .bat file, and then execute the .bat file:
STEP 1: Create a .bat file (script.bat) with the context of the bteq an the parameters ex:

DEL script1.txt

ECHO .LOGON,%4; >>    script1.txt

ECHO SELECT TOP 10 * FROM %1.%2; >> script1.txt

ECHO .LOGOFF; >> script1.txt

ECHO .EXIT; >> script1.txt

bteq < script1.txt


each %# is a parameter so this example has four parameters.


STEP 2: run de .bat file as this wayin the cdm:


script.bat DB TABLE USER PASSW, in this case every word represent a parameter in the same order DB is %1, TABLE is %2 USER is %3  PASSW is %4 , so when you exec the .bat the parameters will be substituted in that order.


I think this is not completly a funtional solution, y someone can help us to obtain a better solution it will be great,  I´m looking for another solution in Teradata Realease 15.00 or maybe its better use another Utilities. Thanks.

You must sign in to leave a comment.