Question: how to export data from temp table in sql server?
Answer: Create a permanant table, insert the data from the temp table into the permanant table and BCP from there, then drop the table. Create an SSIS package using the query you had to create and populate the temp table an use that as your data source to export you your flat file.