Ananth Francis
Ananth Francis

Reputation: 161

How to create batch file to execute multiple DB2 queries

I have to run some DB2 SQL queries more frequently.It is taking lot of time to do that manually. For that, I am planning to create batch file to execute those DB2 SQL commands. So,Please let me know whether it is possible to create windows batch file to run set of DB2 sql queries.

Upvotes: 4

Views: 12446

Answers (1)

bhamby
bhamby

Reputation: 15450

You can save a .sql file to your hard drive, and execute it using the DB2 command line using:

db2 -vtf C:\path\to\somefile.sql

-v echoes the command text back to the command line

-t sets the statement terminator to ;. If you want to use something else (creating stored procedures for example), you can use -td__ where __ represents up to two characters you can use as the terminator. Alternatively, you can use --#SET TERMINATOR __ inside your batch file

-f tells the command line to load the commands from the file.

See other command line options here.

Upvotes: 8

Related Questions