如何将选择查询的结果导出到sql server上的文本文件(* .txt) [英] how can export results from a select query to text file(*.txt) on sql server

查看:96
本文介绍了如何将选择查询的结果导出到sql server上的文本文件(* .txt)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好社区



我需要知道,如何将选择的程序存储区中的所有结果导出到文本文件。





为了简化我的问题,这里有一个步骤图:



1.执行SP,2。从表y中获取数据进行数据处理 - > ;; 3.显示结果...在步骤3之后,必须将结果导出到文本文件



我使用的sql server是sql 2000但是有人知道另一个版本没关系。



如果我的问题信息很差,请告诉我



非常感谢< / pre>

hello community

I need to know, how can I export all results from a select of a procedure store to text file.


To simplify the idea of my question, here is a step diagram:

1. Execute SP , 2. bring the data from table y make the data process ->; 3. show results...after step 3, must be the results exportation to text file

the sql server that I use is sql 2000 but is someone know by another version doesn't matter.

If my question is poor on information, please let me know

Thanks a lot</pre>

推荐答案

检查以下答案

SQL Server:将查询导出为.txt文件 [ ^ ]


看看 gsqlcmd [ ^ ]命令行实用程序。



例如,您可以将数据导出为text,csv或htm:

Take a look at the gsqlcmd[^] command line utility.

For example, you may export data as text, csv, or htm:
gsqlcmd sql "EXEC dbo.sp_MyProcedure" output.txt

gsqlcmd sql "EXEC dbo.sp_MyProcedure" output.csv

gsqlcmd sql "EXEC dbo.sp_MyProcedure" output.htm



其中sql是目标连接的名称。


where sql is a name of the target connection.


这篇关于如何将选择查询的结果导出到sql server上的文本文件(* .txt)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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