Here’s a step-by-step guide to creating a new task in windows task scheduler and adding a BAT file. It will upload data from a flat file to an oracle table. The prime point you will know here is how to add SQL Loader script to the BAT file.
Table of contents
Create a Task in Windows task Scheduler
Search for a Task scheduler in windows search.
Click on create a New task
Add details for the General tab
Add trigger details: Click on the New tab
Enter the Date and Time of frequency to run the scheduled job.
In the actions tab, you need to attach the BAT file.
Here’s my previous post on running SQL Loader script at Command Prompt. Add the same to the BAT file. So you can automate the task in the Windows task Scheduler.
Creating a BAT file
Go to any drive you wish. For example, in the D:/ drive, open notepad, and add contents as below:
Save it as “Myscript.bat”:
"C:\Users\user\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\System Tools\Command Prompt.lnk" /c "SQLLDR database-name/password@portname control=D:/p.ctl, skip=1"
The first piece of code: “C:\Users\user\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\System Tools\Command Prompt.lnk” tells open the CMD.
The second piece /c tells CMD to open, execute and close it. The third piece is the actual script to run.
Just add the script to the Actions tab.
That’s all. Your scheduled job will execute as per the time you choose.