Exporting from SQL Server to Excel with column headers?

前端 未结 4 713
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-13 12:48

I have a query that has approximately 20 columns and I would like to export this to an Excel file with the column headers.

I thought this would be easy to figure out bu

相关标签:
4条回答
  • 2021-02-13 12:52

    That is the default if you use the Import/Export wizard. You can also save this out to an SSIS package if you want to customize the export.

    0 讨论(0)
  • 2021-02-13 13:00

    I typically do this by simply click the upper left corner in the results grid, copy, and then paste into Excel. There is one catch, you need to go into options->query results-> SQL Server->results to grid (or text if you want to save to file for import into excel) and turn on include column headers when copying or saving the results. I find this works great.

    0 讨论(0)
  • 2021-02-13 13:07

    Tools --> Options, Select "Query Results" --> "SQL Server" --> "Results to Grid" and "Results to Text" (images below):

    enter image description here

    enter image description here

    0 讨论(0)
  • 2021-02-13 13:14

    This script rocks BCP to Export data to excel

    0 讨论(0)
提交回复
热议问题