如何使用 SQL CMD 并在每次在 sql server 中运行脚本时输出一个新文件?
我有一个如下所示的脚本,我放入一个作业中,它运行并输出一个文件。
sqlcmd -E -i t:\export\test.sql -o t:\export\MyReport.txt
当我运行它时,它运行良好并将文件输出到指定的位置。
我想要做的是,有没有一种方法可以添加到代码中,以便每当此脚本运行时,它都会创建一个新文件,而不删除上次运行生成的旧文件?基本上,如果作业运行 10 次,我就会有 10 个不同的文件。
谢谢。
I have a script like below i put in a Job and it runs an outputs a file.
sqlcmd -E -i t:\export\test.sql -o t:\export\MyReport.txt
When i run this, it works well and outputs a file to the location specified.
What i am looking to do is, is there a way i can add to the code so that anytime this script runs, it will create a new file and not remove the old file the previous run generated? Basically if the job runs 10 times, i have 10 different files.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需在文件名中添加一些时间即可。
Simply add some time added to your file name.