Click here to Skip to main content
15,888,195 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello.

I have table T1 on MS SQL Server 2005.

I want to write result of
SQL
select * from T1
for xml raw, elements

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.
Posted

Below forum will help you to resolved your issue.
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926[^]
 
Share this answer
 
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)"

or
Using Command Prompt
start>>RUN>>cmd>>
SQL
sqlcmd -E -S(Local)\InstanceName -dmaster -iC:\myQuery.txt -oC:\Output.txt

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900