Tuesday, February 14, 2012

Create CSV from SQL query

Hello,
I would like to be able to create a csvfile when I execute a query in
SQL. Is there an SQL command or procedure that allows for this?
If a query is executed, how could I dump the results into a CSV file (or
any other format - but preferibly csv). I would rather not used
externalized tools (ie write my own echo or cscript, or DLL to write to a
file within a SQL function or procedure).
Thank you
James.James,
You can do it easily in a DTS package. Just create a
source server and an output text file(you can set the
delimter in the file properties. Create a transform data
task and place your query in the task. Then run the DTS
package to output the results to the file.
I hope that helps.
Derek
>--Original Message--
>Hello,
> I would like to be able to create a csvfile when I
execute a query in
>SQL. Is there an SQL command or procedure that allows
for this?
> If a query is executed, how could I dump the results
into a CSV file (or
>any other format - but preferibly csv). I would rather
not used
>externalized tools (ie write my own echo or cscript, or
DLL to write to a
>file within a SQL function or procedure).
> Thank you
> James.
>
>.
>

No comments:

Post a Comment