All Forums Database
prateek.saxena 12 posts Joined 08/13
24 Nov 2013
Automate my Teradata queries

I have some teradata codes which I want to automate. It should be done in a way that they can execute themselves on a specific date/time of a month. 
Any help will be appreciated.

Regards, Prateek
ulrich 816 posts Joined 09/09
24 Nov 2013

Calling the SQLs from BTEQ and schedule the BTEQ calls with a scheduler, cron etc....

feel free to donate bitcoin:12kgAUHFUqvG2sQgaRBXFhCwyf9HXdkGud

prateek.saxena 12 posts Joined 08/13
24 Nov 2013

Hey, thank for replying. Can you please elaborate a bit?


M.Saeed Khurram 544 posts Joined 09/12
24 Nov 2013

Hi Parteek,
You need to put your SQL code inside Bteq as said by Ulrich. BTEQ is a Teradata sql processing tool, if you need further information about Bteq, do let me know. if you have an idea of Bteq then put your code in Bteq and use some job schedular to automate the Bteq script calls.
There are numerous job schedulars available in market, a list is available at
You can also use linux feature as given at below URL


M.Saeed Khurram 544 posts Joined 09/12
24 Nov 2013

You can read the following blog to have a basic idea of Bteq


Raja_KT 1246 posts Joined 07/09
25 Nov 2013

Hi Prateek,


You can put your modularized codes according to the way they can execute themselves with all the logics, conditional and branching required with date/time inside a stored procedure. If it is just one one chunk of function or subject area, then you can put in one proc. If you have many procs and inter dependencies, then you can use schedulers. The best practice is to have audit log and restartability.


There are so many schedulers available.


Thanks and regards,


Raja K Thaw
My wiki:
Street Children suffer not by their fault. We can help them if we want.

prateek.saxena 12 posts Joined 08/13
25 Nov 2013

Thanks guys, this was helpfull. :)


S_GALILEO 8 posts Joined 12/15
01 Feb 2016

Dear all, 
I have the same enquiry: I want to schedule my Teradata query to run every day at a given time but I am not sure I have understood the approach with BTEQ... Could you please elaborate more about this solution? An example would be more than appreciated. 
Best regards. 

Ckp 11 posts Joined 11/15
05 Feb 2016

Say if I need to refresh the content of my table at 1:00 AM every friday,
I will use the following btq script (which includes insert query) and unix scheduler like cron:
btq script example :
.logon <teradata serverName>/<UserId>,<Password>;;
drop table DB.<Table>;
create table DB.<Table>
(store_Id smallint);
.IMPORT DATA FILE=/<path to file>/in.dat
USING  storeId (smallint)
insert into DB.<Table>(store_Id) values (:storeId)
CRON Example :
00 1 * * 5 sh  /<path to your script>/ 1>>/<path to log>/Script.log 2>&1
00- Minutes
1 -  Hour
* - Every
5 - 5th day of week (Starting from Monday so in this case Friday)

You must sign in to leave a comment.