批处理文件连接到数据库服务器,以csv文件的形式将表获取到应用程序服务器 [英] batch file connect to database server to get table in the form of csv file to application server

查看:120
本文介绍了批处理文件连接到数据库服务器,以csv文件的形式将表获取到应用程序服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我对批处理文件脚本有一个要求,但我是新手编写批处理文件脚本。



我希望有人能帮我解决这个问题。



这是要求。

1)我有应用程序和数据库服务器。

2)在应用程序服务器上运行批处理文件。

3)连接到数据库服务器。 br />
4)运行DB服务器中特定数据库表中批处理文件中的查询。

5)输出应导出到.csv(excel)文件中

6).csv文件应转移到App服务器文件夹

7)如果可能的话,在每个动作上维护应用服务器中的日志。

我在谷歌搜索代码后尝试了很多但是我不能...



任何人都可以帮我解决上述要求的批处理文件代码。

解决方案

批处理中几乎无法访问此处的任何内容。您可以在批处理中执行此操作,但前提是您使用它来运行某些应用程序以进行数据库操作,记录,几乎所有内容。但是如果你不得不编写这样的应用程序,它会变得非常值得怀疑:为什么要使用批处理?



但是,这取决于你所谓的批处理。以上所有内容都不适用于功能更强大的批处理工具PowerShell:

http:// en .wikipedia.org / wiki / PowerShell [ ^ ] ,

http://technet.microsoft.com/en-US/scriptcenter /dd742419.aspx [ ^ ]。



PowerShell非常强大。简而言之,粗略地说,您可以使用PowerShell执行几乎任何可以使用.NET的操作。例如,对于数据库工作,您可以引用ADO.NET程序集并使用ADO.NET,等等...



-SA

Hi,
I got a requirement on the batch file script but I am new to write the Batch file script.

I hope can anyone will help me out on the requirement.

Here is the requirement.
1) I have Application and Database servers.
2) Batch file run on Application server.
3) connect to Database server.
4) run the query present in the batch file in the table of the particular database in DB server.
5) output should be exported into a .csv(excel) file
6) .csv file should be transferred to App server folder
7) if possible maintain the log in app server on each action.
I tried very much after searching the code in google and i cant..

Can anyone please help me with the batch file code with the above requirement.

解决方案

Almost anything here is not accessible to batch. You can do it in the batch, but only if you use it to run some applications for database operations, logging, pretty much everything. But if you have to write such applications anyway, it would become quite questionable: why using the batch?

However, it depends on what you call "batch". All of the above is not applicable to the much more powerful batch facility, PowerShell:
http://en.wikipedia.org/wiki/PowerShell[^],
http://technet.microsoft.com/en-US/scriptcenter/dd742419.aspx[^].

PowerShell is really extremely powerful. In brief, roughly speaking, nearly anything you can do with .NET you can do with PowerShell. For example, for database work, you can reference ADO.NET assemblies and use ADO.NET, and so on…

—SA


这篇关于批处理文件连接到数据库服务器,以csv文件的形式将表获取到应用程序服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆