Wednesday, August 1, 2012

Run multiple commands in db2cmd

In Windows DOS, you need to run db2cmd before you can do any db2 command. If you want to run multiple commands, usually you can output the commands into a file and call db2cmd like this:
db2cmd -c db2 -tvf cmd_file.sql
But if you don't want to generate a file, here is how
db2cmd -c db2 connect to mydb user me using passwd && db2 select * from my_table && db2 terminate
DOS uses && to run multiple commands in one line.