How to export data into .csv file thru query

  • Hi,

    I have a select query to retrieve the data. I want to export the data into a .csv file in a specified location thru query (Not Manually saving into csv file or using the BCP utility).

    Kindly suggest.

    Ryan
    //All our dreams can come true, if we have the courage to pursue them//

  • If you need this is a repeatable and automated fashion , as i guess as you say Not manually, then SSIS is probably a safe bet.



    Clear Sky SQL
    My Blog[/url]

  • Actually I want it from the query in SSMS specifying the location name and this is not repeatable.

    Ryan
    //All our dreams can come true, if we have the courage to pursue them//

  • Results To Grid,

    R-Click - Save As....

    Should do you



    Clear Sky SQL
    My Blog[/url]

  • Hi,

    you can create a job and run the query in the job. Then use xp_sendmail with the parameter @attach_results.

    IT should be repeatable as per the frequency of the job set by you. but remeber this feature is deprecated for future versions.

    :w00t:

  • This is a common request. In my opinion "in-process EXPORT" functionality is a feature that would be very useful.

    See this similar post:

    http://www.sqlservercentral.com/Forums/Topic1061652-392-1.aspx

    Here are some workarounds in preference order:

    1. SSIS / DTS called by SQL Agent or other external caller

    2. bcp called by SQL Agent or other external caller

    3. bcp via xp_cmdshell called within stored procedure (security considerations)

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply