使用单个bat文件一次性执行多个文件

发布于 2024-10-10 02:03:41 字数 259 浏览 0 评论 0原文

我正在使用批处理文件来执行多个sql 文件。 所以我创建了一个bat文件,如下所示:

osql -S ServerName -U user -P password -d DBTest -i C:\SQLFILES\Test1.sql
pause

上面的代码执行单个文件Test1.sql,如果我需要执行下一个文件,我必须再次修改bat文件并更改文件名。我有10个这样的sql文件我想把他们一个接一个地处决。有没有办法一次性做到这一点?

I am using a batch file to execute multiple sql files.
So I have created a bat file like:

osql -S ServerName -U user -P password -d DBTest -i C:\SQLFILES\Test1.sql
pause

The above code executes a single file Test1.sql and if I need to execute the next file I have to again modify the bat file and change the file name.I am having 10 such sql files and I want to execute them one after another. Is there any way to do this at one go?

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

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

发布评论

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

评论(1

夏の忆 2024-10-17 02:03:41

好吧,你绝对可以做的就是给你的 BAT 文件一个参数(这样你就不必不断地更改 BAT 文件内容...):

ExecSQL.bat:

osql -S ServerName -U user -P password -d DBTest -i %1
pause

然后你可以调用它像这样的批处理文件:

c:\> ExecSQL C:\SQLFILES\Test1.sql

然后

c:\> ExecSQL C:\SQLFILES\Test2.sql

等等

Well, what you could definitely do is give your BAT file a parameter (so you don't have to constantly change the BAT file contents...):

ExecSQL.bat:

osql -S ServerName -U user -P password -d DBTest -i %1
pause

and then you can call this batch file like this:

c:\> ExecSQL C:\SQLFILES\Test1.sql

and then

c:\> ExecSQL C:\SQLFILES\Test2.sql

and so forth

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