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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query results into a text file

Status
Not open for further replies.

sliver

Programmer
Nov 16, 2000
23
US
The title just about says it all I have a query that I want to turn into a text file with some sort of deliminator I need to do this with a coupple of different querys one with 3 results per line one with 7 so on and so on. I feel this should be easy but I havent been working for about 6 weeks and my brain is mush... thank you in advance.
 
Hey Sliver,

One quick way is just to loop through the results with a <cffile action=&quot;append&quot;...> like this.

<cfoutput query=&quot;q1&quot;>
<cffile action=&quot;append&quot; file=&quot;output.txt&quot; output=&quot;#q1.field1#,#q1.field2#,...&quot;>
</cfoutput>

You'll run into problems if your data contains commas though so I would choose a delimeter that you know won't be in the data. I don't know offhand if the cffile tag puts a carriage return at the end of the output so you may need to add &quot;#chr(13)##chr(10)#&quot; to the end of your output string to ensure each row is on a separate line.

Hope this helps,
GJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top