有没有办法从命令行中禁止 SQLCMD 中的“受影响的 x 行”?

有没有办法从命令行中禁止 SQLCMD 中的“受影响的 x 行”?

我正在运行 MSBuild 脚本,不希望它阻塞我在构建服务器上的日志。

我不希望在每个脚本中都添加“ SET NOCOUNT ON”,所以如果有一种方法可以从命令行执行,那就太好了。

103496 次浏览

What about creating a startup script with SET NOCOUNT ON in the script (assign the script to the SQLCMDINI environment variable). http://msdn.microsoft.com/en-us/library/ms162773.aspx

The -i and -q options are mutually exclusive.

Create a file named setnocount.sql with the content:

SET NOCOUNT ON;

And you might be able to do -i setnocount.sql,otherscript.sql using the multiple files feature and effectively an "included" common first file.

You can also run multiple lines in the -Q parameter, separated by semicolon, like below

eg:

-Q "set nocount on;select * from table;delete from table where some_condition=true"