将SQL查询输出到文本文件 [英] Output an SQL Query to a text file

查看:225
本文介绍了将SQL查询输出到文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




如何将SQL查询的结果写入文本

文件?


我在在线帮助文​​件中找不到任何信息。


例如,我想得到的结果:


SELECT *来自TableA


要写入文件result.txt

Alex

Hi,

How would I go about writing the results of an SQL query to a text
file?

I cannot find any info in the Online help files.

For example, I would like the results of:

SELECT * FROM TableA

To be written to the file result.txt
Alex

推荐答案

打开查询分析器。转到查询并选择结果到文件....和

执行期间,它将提示文件名....

Open query analyzer. Go to Query and select Result to file.... and
during execution, it will prompt a file name....


谢谢,但我不能这样做。


这个必须查询必须对最终用户不可见。


例如,如果a用户在我的系统上执行某些功能,我希望
对他们选择的内容执行查询并将结果输出到

文件。我不希望我的用户选择另存为等。

Thanks but I cannot do that.

This must query must be invisible to the end user.

For example, if a user performs some function on my system, I wish to
execute a query on what they have selected and output the results to a
file. I do not want my user to be selecting Save As etc..


首先你的问题不明确。我仍然不确定你是什么

试图完成。


首先,如果你有一个你不希望你的用户知道的查询,请将其包裹起来

在存储过程中将其安排在工作中并让用户执行

工作。


另一个简单的方法是创建一个dts并让用户运行dts,

应该运行查询并输出文件。


希望这有助于..!

First your question is not clear. I am still not sure what you are
trying to accomplish.

First if you have a query that you dont want your user to know, wrap it
up in a stored proc and schedule it in a job and let the user execute
the job.

Another easy way is to create a dts and let the user run the dts that
should run the query and output the file.

Hope this helps..!


这篇关于将SQL查询输出到文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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