I am executing multiple DB2 SQL commands frequently. It is taking lot of time to do this manually so I want to automate this using a batch file.
How can I do this?
perhaps to merge all the files into a single file, COPY a.sql + b.sql + c.sql d.sql
, creating a single .sql file.
Use sqlcmd with Scripting Variables
Using SQLCMD to loop through list of servers
Centralized Data Collecting, Using SSIS
SQL Server – Executing Multiple Script Files Using SQLCMD
Instead of trying to set up a batch file to handle the issue, is it possible write a stored prcedure instead? In most cases a stored procedure is far more efficient, some databases will allow you to pin them in memory for faster access as well as optimixing its execution path. Of course, some of this may depend on exactly what you want to accomplish the the SQL commands you are issuing in the first place.
Some RDBMS will allow you to have global stored procedures that can be executed against the system talbes and with some restrictions (or a lot of work) on any other database on the system. Others will only allow stored procedures that can run on a particular database.
Once you have a stored procedure set up, you simply use a simple call to the database to execute the stored procedure.
Hi Bruce E,
Thank you for your comments.
I will try your idea.