Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

create a batch file to execute sql

e0f3d7a3-d1ff-4ba0-b200-398c523354fcJul 21 2017 — edited Jul 21 2017

  

 

I am using SQL developer and I do not have permission to schedule in developer itself. I would like to schedule queries to run using Task Scheduler but I have never created a .bat file so I am unsure what I need to do. I'd like it to create an excel file. Thanks.

I tried something like this. It will put an excel file in the folder but doesn't seem to run the sql.

@ECHO OFF  
SET SQLCMD="C:\sqldeveloper\sqldeveloper\bin\sql.exe"
SET PATH="C:\Users\smith\Documents\Villella"
SET SERVER="sample" SET DB="world"
SET LOGIN="smith" SET PASSWORD="Junk"
SET OUTPUT="C:\Users\test.xlsx" 

CD
%PATH% 

ECHO
%date% %time% > %OUTPUT% 

for
%%f in (*.sql) do ( %SQLCMD% -S %SERVER% -d %DB% -U %LOGIN% -P %PASSWORD% -i %%~f >> %OUTPUT% )
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 18 2017
Added on Jul 21 2017
1 comment
2,484 views