4

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.

1 Answer 1

8

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.