Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing the results of a query to a file?

Status
Not open for further replies.

Robbomobb

Technical User
May 27, 2003
21
SE
How do i write the results of a query to a text file?

The query uses the "PRINT" command to display the reults from the query in the display pane in queryanalyzer, but what i want is to write the result into a text file which can be attached to a mail later on.

I´ve scheduled the script as a job and configred it to write the result to a text file. It works fine but i recieve an annoying [SQLSTATE 01000] at the end of each row in the text file.

How do i solve this?

Thankful for every reply
 
from query analyzer

click on the query menu and then click on Results to File,
once you have done this, highlight your query and run it, before it will run you will be prompted to enter a file name.
 
Just one more thought.
xp_sendmail can send your query output directly to someone if you have sql mail setup...

Very cool stuff


Rob
 
Thanks for the input. I´ve tried both of the sullotions given and they worked just fine.

I´m gonna go with the xp_sendmail and attach the results from the query.

Thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top