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

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

  • 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.

    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)

  • 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.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • 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.

    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 18 (of 18 total)

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