This script adds the ' and , right in the SQL. It concatenates all the fields you need into a single comma seperated column called "line". ValueList() creates a list from a query object; in this case we set the delimiters to the windows "newline/carriage return" sequence. This makes it very easy to insert the whole query into a file with a sing CFFILE call.
(note that you may need to use CFFILE action="write" if the file does not allready exist) > > > ><CFQUERY NAME="GetDocs"...> > > SELECT > > '"' + RTRIM(FieldA) + '"' + ',' + > > '"' + RTRIM(FieldB) + '"' + ',' + > > '"' + RTRIM(FieldC) + '"' > > AS line > > > > FROM > > table > ></CFQUERY> > > > ><!--- create the file content ----> > ><CFSET filecontent = ValueList(GetDocs.line,"#CHR(13)##CHR(10)#")> > > > ><!--- and save it ---> > ><cffile action="APPEND" file="#csvfile#" output="#filecontent#"> > > > > > ______________________________________________________________________ Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm FAQ: http://www.thenetprofits.co.uk/coldfusion/faq Archives: http://www.mail-archive.com/[email protected]/ Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

