When running a script in SQLCMD, is there a setting, parameter or any other way of making it effectively run a GO command at the end of each SQL statement?
This would prevent the need to insert periodic GO commands into very large scripts.
No.
SQLCMD would have to implement a full T-SQL parser itself in order to determine where the statement boundaries are. Whereas as it currently exists, all it has to do is find lines with "GO" on them.
Determining statement boundaries can be quite tricky, given that ";" terminators are still optional for most statements.
Hmmm, I guess this is not going to help but is an answer to your question:
http://msdn.microsoft.com/en-us/library/ms162773.aspx
-c cmd_end Specifies the batch terminator. By default, commands are terminated and sent to SQL Server by typing the word "GO" on a line by itself. When you reset the batch terminator, do not use Transact-SQL reserved keywords or characters that have special meaning to the operating system, even if they are preceded by a backslash.
Especially the last sentence sounds daunting....
If all your lines end in ; and there is no ; any where else (in text fields for example) try
sqlcmd -c ;
来源:https://stackoverflow.com/questions/4944165/can-you-make-sqlcmd-immediately-run-each-statement-in-a-script-without-the-use-o