osql
Links
Also see sqlcmd.
Sample
Script
To run the list__mydb.sql
script on localhost
:
osql.exe -E -i"list__mydb.sql"
-E
uses a trusted connection instead of requesting a password (must be upper case).Use the
-d
parameter to specify a database name e.g.-d "mydb"
SQL
Not tested!!!
To run SQL directly on the server MyServer
:
osql.exe -E -Q"DROP DATABASE mydb"
osql.exe -S MyServer -E -Q"RESTORE DATABASE MyDB FROM disk = '\\MyServer\Backups\mydb.bak'"