Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Execute SQL from batch file

I'm new to batch files scripting.

All I want is creating a batch file that calling SQL file and store results in text file .

Can anyone help me, your help is highly appreciated,

This is the first time I need to create such files.

like image 787
Manaysah Avatar asked Sep 22 '26 23:09

Manaysah


2 Answers

using a batch file:

save and run this:

@echo off
sqlplus -s -l user/pass@yourdb @yoursql.sql>your_log.log

p.s. be sure to have the last line of your sql script as exit; or the batch file will hang.

like image 123
DazzaL Avatar answered Sep 24 '26 23:09

DazzaL


sqlcmd -S sqlservername -i yoursqlfile.sql -U username -P password -o outputfile.txt
like image 33
Andomar Avatar answered Sep 24 '26 23:09

Andomar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!