Saving results with headers in Sql Server Management Studio

后端 未结 10 2241
长发绾君心
长发绾君心 2020-12-13 01:35

I am using SQL Server Management Studio.

I wish to save the results of a query to an excel file.

I choose \"save as\" and then save to CSV file which I ca

10条回答
  •  無奈伤痛
    2020-12-13 01:46

    The settings which has been advised to change in @Diego's accepted answer might be good if you want to set this option permanently for all future query sessions that you open within SQL Server Management Studio(SSMS). This is usually not the case. Also, changing this setting requires restarting SQL Server Management Studio (SSMS) application. This is again a 'not-so-nice' experience if you've many unsaved open query session windows and you are in the middle of some debugging.

    SQL Server gives a much slick option of changing it on per session basis which is very quick, handy and convenient. I'm detailing the steps below using query options window:

    1. Right click in query editor window > Click Query Options... at the bottom of the context menu as shown below:

    1. Select Results > Grid in the left navigation pane. Check the Include column headers when copying or saving the results check box in right pane as shown below:

    That's it. Your current session will honour your settings with immediate effect without restarting SSMS. Also, this setting won't be propagated to any future session. Effectively changing this setting on a per session basis is much less noisy.

提交回复
热议问题