How to write csv output files one per temp table in one query

Tags:
T-SQL
In one query I build four temp tables then I want to write the data from each temp table to its own filename. Is this possible?
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

This depends on what SQL server you’re using (MSSQL, MySQL, SQLite, PgSQL, etc…)  But from what I’ve seen they all have a OUTFILE or OUT syntax that will write data out to a file, and some support automatically formatting it as CSV.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • carlosdl
    Do you know how to write to a file from t-sql?

    I just want to clarify if that is what you are asking help with, or if you know how to write to files, but the fact that you need a different file for each temp table is what is actually becoming an issue.
    85,865 pointsBadges:
    report
  • carlosdl
    There is only one "SQL Server".  The one from Microsoft.
    85,865 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: