John's answer is the correct one for doing it on the CF server side. Here's how I would do it on the SQL server side. For MySQL:
SELECT * INTO OUTFILE '/location/of/file.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n' FROM AnyTable For MSSQL, it can be simple or complicated: simple: 1. Run your query in SQL Server Management Studio 2. Highlight the resultset 3. Copy/paste into excel 4. Save as CSV complicated, run BCP command line utility on the SQL Server: c:\>bcp DatabaseName.dbo.TableName out C:\fileLocation.csv -c -t "," -S SERVERNAME -U username -P password Have fun! On 2/2/2011 11:43 AM, John M Bliss wrote: > http://cflib.org/udf/QueryToCsv > > On Wed, Feb 2, 2011 at 1:31 PM, Richard Steele<r...@photoeye.com> wrote: > >> Is there an easy way to export SQL query data into a tab delimited or CSV >> format? I know I can do this with a loop and variables, but it seems like >> there should be an easier way. (my query has 100+ column names!). Thanks in >> advance. >> >> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Order the Adobe Coldfusion Anthology now! http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:341820 Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm