SQL Server Performance Forum – Threads Archive
Saving data to a Text File
I want to save data from a SELECT statement to a text file.What is the code for doing this?Read about bcp in sql server help file Madhivanan Failing to plan is Planning to fail
Check this topic:
http://www.sql-server-performance.com/forum/topic.asp?TOPIC_ID=10257
You can also use the following commands to write to a file if you wanted to do it in a sp or something else. Once you open the file, you can write to it as many times as you want before you close it. If the file does not exist, it will create it. If the file does exist, it will append to it. *************************************************************************************
OK well I can’t seem to post the part declaring a Scripting.FileSystemObject so the code is at the address shown below. Sorry I just get an error each time.
************************************************************************************* I believe I got this script at the following address. The person has this in a stored procedure for file output.
http://www.databasejournal.com/features/mssql/article.php/3427231 John
If its a one-off then from Query analyzer you can save the results to a text file [<img src=’/community/emoticons/emotion-1.gif’ alt=’

]]>