有没有办法抑制“x rows受影响”从命令行在 SQLCMD 中?

发布于 2024-08-17 03:50:26 字数 147 浏览 5 评论 0原文

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

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

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

Is there a way to suppress "x rows affected" in SQLCMD from the command line?

I'm running an MSBuild script and don't want it clogging up my log on my build server.

I'd rather not have to add "SET NOCOUNT ON" in every script, so if there's a way to do it from the command line, that would be fantastic.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

南薇 2024-08-24 03:50:26

创建一个启动脚本并在脚本中设置 SET NOCOUNT ON 怎么样(将脚本分配给 SQLCMDINI 环境变量)。 http://msdn.microsoft.com/en-us/library/ms162773.aspx

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

ι不睡觉的鱼゛ 2024-08-24 03:50:26

-i-q 选项 是互斥的

创建一个名为 setnocount.sql 的文件,其内容为:

SET NOCOUNT ON;

您也许可以使用多文件功能执行 -i setnocount.sql,otherscript.sql 操作,并有效地“包含”公共第一个文件。

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.

糖果控 2024-08-24 03:50:26

您还可以在 -Q 参数中运行多行,用分号分隔,如下所示

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

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"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文