Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create batch file to execute multiple DB2 queries

Tags:

db2

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.

like image 783
Ananth Francis Avatar asked Feb 15 '23 19:02

Ananth Francis


1 Answers

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.

like image 64
bhamby Avatar answered Feb 18 '23 08:02

bhamby