vamsi_uk
asked on
Run SQL statements and scripts from Windows batch file
Hi Experts,
I want to have a windows batch file which will run some sql commands or scripts when i execute the batch file. I have tried to create a simple batch file which will connect to the database and execute a sample SQL statement. But this is only connecting to the database and stops at the SQL prompt.
contents of the batch file:
########################## ####
set ORACLE_SID=db1
set ORACLE_INSTANCE=db1
sqlplus / as sysdba
@test.sql
########################## ####
Could someone please tell me how i can run sql statements or scripts from the batch file
Thanks
I want to have a windows batch file which will run some sql commands or scripts when i execute the batch file. I have tried to create a simple batch file which will connect to the database and execute a sample SQL statement. But this is only connecting to the database and stops at the SQL prompt.
contents of the batch file:
##########################
set ORACLE_SID=db1
set ORACLE_INSTANCE=db1
sqlplus / as sysdba
@test.sql
##########################
Could someone please tell me how i can run sql statements or scripts from the batch file
Thanks
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
hi guys,
sorry for not responding quickly as i was away on work. I will test your suggestions today and let you know how it goes.
thanks
sorry for not responding quickly as i was away on work. I will test your suggestions today and let you know how it goes.
thanks
ASKER
thanks guys, that worked fine
i.e.,
>Â sqlplus /nolog @test
where test.sql contains
-- log into sqlplus as sys
connect / as sysdba;
-- run sql stuff
.....