Search code examples
sqloracle-databasebatch-filereturn-valuensis

Can .bat file execute an sql query and return a value?


How can I call a query from a .bat file? (say my query is: select version from system).

Can my .bat file save the output that this query returns? I wanna use this output in my NSIS script.


Solution

  • For Oracle:

    How can I issue a single command from the command line through sql plus?

    @echo select version from system; | sqlplus username/password@database 
    

    You can either pipe the output to a file and use that, or wrap this in a for command to parse the output within your batch file.