将选择结果导出到文件. [英] Export result of select to file.

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

问题描述

你好.

我在MS SQL Server 2005上有表T1.

我想写
的结果

Hello.

I have table T1 on MS SQL Server 2005.

I want to write result of

select * from T1
for xml raw, elements


归档.

我可以仅使用sql server来解决此问题吗?我只想执行存储过程,并可能向它发送输出文件路径.

对我来说,当前的解决方案是从我的C#代码编写查询结果.但是T1中有很多列,查询返回接近1万行.

谢谢.


to file.

Can I solve this problem using only sql server? I would like only to execute stored procedure and maybe send output file path to it.

Current solution for me is to write result of query from my c# code. But there are many columns in T1 and query return near 10k rows.

Thank you.

推荐答案

以下论坛将帮助您解决问题.
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926 [ ^ ]
Below forum will help you to resolved your issue.
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926[^]


Open SSMS-Analyzer>>New Query Window>> Paste all your queries
select option Query>>Results to>> Results to File
or use
short cut "Result to File(ctrl+shift+F)"



使用命令提示符
开始>>运行>> cmd>>


or
Using Command Prompt
start>>RUN>>cmd>>

sqlcmd -E -S(Local)\InstanceName -dmaster -iC:\myQuery.txt -oC:\Output.txt


InstanceName = sqlserver实例名称
C:\ myQuery.txt =将上述所有sqlstatments放置在此文件中
C:\ Output.txt =输出文件


InstanceName = sqlserver instance name
C:\myQuery.txt = place all the above sqlstatments in this file
C:\Output.txt = output file


这篇关于将选择结果导出到文件.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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