Sql Server 2005 has a command line tool named sqlcmd. MySQL has a
command line tool named mysql. Oracle has a command line tool
called sqlplus. They can all be used for interactive query
processing and batch scripts processing. They do similar things,
albeit in different ways. They are functionally equivalent.
For Sql Server 2005, when in interactive mode of sqlcmd, use
:r c:MyFolderMyScript.sql
to read and execute a script file. You may have to type
go
afterwards, if the last line of the script file does not end with
the word go.
To use sqlcmd in batch mode, that is, to run a sql script and
then get out, use:
sqlcmd -i c:MyFolderMyScript.sql -S MyServerName -E
Replace -E with -U LoginName if you use Sql authentication
For MySQL, while in interactive mode of mysql, use
. c:MyFolderMyScript.sql (on Windows)
Note there should be a backward …
[Read more]