You can easily run Transact-SQL (T-SQL) script files (with extension .sql) via the commandline utility sqlcmd:
sqlcmd -S Server\Instance -i C:\path\to\SomeScript.sql
By default, the output is written to the command prompt. You can also save the output to a file:
sqlcmd -S Server\Instance -i C:\path\to\SomeScript.sql -o C:\path\to\TheOutput.txt
Note that when using this, no output is written in the command prompt window.
Send a link to this post to yourself or a friend.