How to export SQL Server 2005 query to CSV

后端 未结 13 2642

I want to export some SQL Server 2005 data to CSV format (comma-separated with quotes). I can think of a lot of complicated ways to do it, but I want to do it the right<

13条回答
  •  攒了一身酷
    2020-12-04 15:52

    In Sql Server 2012 - Management Studio:

    Solution 1:

    Execute the query

    Right click the Results Window

    Select Save Results As from the menu

    Select CSV

    Solution 2:

    Right click on database

    Select Tasks, Export Data

    Select Source DB

    Select Destination: Flat File Destination

    Pick a file name

    Select Format - Delimited

    Choose a table or write a query

    Pick a Column delimiter

    Note: You can pick a Text qualifier that will delimit your text fields, such as quotes.

    If you have a field with commas, don't use you use comma as a delimiter, because it does not escape commas. You can pick a column delimiter such as Vertical Bar: | instead of comma, or a tab character. Otherwise, write a query that escapes your commas or delimits your varchar field.

    The escape character or text qualifier you need to use depends on your requirements.

提交回复
热议问题