1.

Solve : help .bat -> MySQL?

Answer»

Hi there,

There is a cammand/script on a FILE .bat to execute a mysql query automatically?

best regards.Normally SQL queries are written in PHP, server level, etc, but if you really want to run in a bat file there is a command line version too. You can use the command-line TOOLS OSQL or SQLCMD. SQLCMD has some extra bells and whistles. For an overview over command-line OPTIONS, once installed, run OSQL -? or SQLCMD -? at the command line.

You can then create SQL files and then call them from the bat file.

You can also pass parameters on the command line or bat file and reference them using %1 through %9. The examples below execute all the ".sql" scripts in the current folder using the server, database, user and password passed as command-line arguments.

For example:
Quote

FOR %%f IN(*.sql) DO SQLCMD -S %1 -d %2 -U %3 -P %4 -I -i "%%f"


A bit of hax-tips if you ask me, use it for good not evil... lol


Discussion

No Comment Found