简体   繁体   English

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

[英]Execute multiple files at one go using a single bat file

I am using a batch file to execute multiple sql files. 我正在使用批处理文件来执行多个sql文件。 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. 上面的代码执行一个文件Test1.sql,如果我需要执行下一个文件,我必须再次修改bat文件并更改文件名,我有10个这样的sql文件,我想一个接一个地执行它们。 Is there any way to do this at one go? 有什么办法可以一次完成吗?

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...): 好吧,您绝对可以做的就是为您的BAT文件提供一个参数(这样您就不必不断更改BAT文件的内容...):

ExecSQL.bat: 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 依此类推

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM