批处理文件中的 SQLCMD - 强制所有输出到一个文件
我们有批处理文件来针对数据库编译文件夹中的所有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我以前从未在批处理中使用过 for 语句,因此我将对其进行一些阅读,但看看您的示例,这似乎应该有效。
批量添加中的下一行
这应将所有 .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
This should append all the .txt files into an All.TXT.