问题描述
你好.
我在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.
推荐答案
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
这篇关于将选择结果导出到文件.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!