批处理文件中的 SQLCMD - 强制所有输出到一个文件

发布于 2024-09-26 03:17:53 字数 281 浏览 0 评论 0原文

我们有批处理文件来针对数据库编译文件夹中的所有 sql 脚本。问题是我们有几千个脚本,它为每个脚本生成一个输出文件。

这使得检查错误变得困难并且需要进行大量清理。有没有办法将所有结果输出到一个文件中?

这是我们使用的脚本:

对于 (.sql) 中的 %%f,执行 sqlcmd -Sservername -i"%%f" -o"%%f.txt" -Uusername -Ppassword -ddatabasename 问候

, 阿尔伯特

We have batch files to compile all the sql scripts in a folder against a database. Problem is that we have a couple of thousand scripts and it makes an output file for each script.

It makes it difficult to check for errors and a lot to do cleanup on. Is there any way to output all of the results to one file?

Here is the script we use:


for %%f in (.sql) do sqlcmd -Sservername -i"%%f" -o"%%f.txt" -Uusername -Ppassword -ddatabasename

Regards,
Albert

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

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

发布评论

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

评论(1

月野兔 2024-10-03 03:17:53

我以前从未在批处理中使用过 for 语句,因此我将对其进行一些阅读,但看看您的示例,这似乎应该有效。

批量添加中的下一行

DEL All.TXT
for %%f in (.txt) do type "%%f" >> All.TXT

这应将所有 .txt 文件附加到 All.TXT 中。

I never used the for statement before in a batch so I am going to do some reading on it but looking at your example this seems like it should work.

Next line in the Batch add

DEL All.TXT
for %%f in (.txt) do type "%%f" >> All.TXT

This should append all the .txt files into an All.TXT.

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