is there any better way to export SQL server data into csv file?

  • WILLIAM MITCHELL

    SSChampion

    Points: 13665

    The OP stated "I want to make a report to let user export data from SQL Server database" so why not consider SSRS?

  • Jeff Moden

    SSC Guru

    Points: 995449

    That's certainly another viable option and it has kind of a user interface built in.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
    "If you think its expensive to hire a professional to do the job, wait until you hire an amateur."--Red Adair
    "Change is inevitable... change for the better is not."

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Jeffrey Williams 3188

    SSC Guru

    Points: 88215

    WILLIAM MITCHELL wrote:

    The OP stated "I want to make a report to let user export data from SQL Server database" so why not consider SSRS?

    This also has the benefit of allowing the user to specify parameters and preview the data before exporting to any allowed format.  What I find in general is that the users actually want it in Excel format - but that isn't native to SQL Server and we end up using CSV so they can open it in Excel.

    SSRS will allow them to ability to export directly to Excel.

    You could also utilize sp_send_dbmail - and include the results as an attachment in an email.  If you want the users to be able to open that email with Excel - you do have to include in the first column some extra data to identify the file as a delimited file, but it can work well.

    [font="Verdana"]Jeffrey Williams
    Problems are opportunities brilliantly disguised as insurmountable obstacles.

    How to post questions to get better answers faster[/url]
    Managing Transaction Logs[/url]
    [/font]

  • Jeff Moden

    SSC Guru

    Points: 995449

    If the ultimate use for the CSV file will be to load into an Excel spreadsheet, you can also make a "Refreshable Spreadsheet" that calls a stored procedure to get the data.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
    "If you think its expensive to hire a professional to do the job, wait until you hire an amateur."--Red Adair
    "Change is inevitable... change for the better is not."

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 4 posts - 16 through 19 (of 19 total)

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