Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Management Studio exports CSV with header from one server and without header from other server

Having one instance of MSSQL Management Studio 2017 connect to two different SQL 2016 Servers. I run queries against a database on each server and save results as CSV to compare with WinMerge.

Problem: One query window saves the CSV with header row, the other query window saves the CSV without header row. I have to edit one file before comparing to get rid of the header row.

Anyone know why I get different results using one instance of Management Studio?

like image 203
Ramon S Avatar asked Oct 29 '25 14:10

Ramon S


2 Answers

Have a look at this option in SSMS: Column Header Option

Make sure that option is checked then close the query window you are using that does not save column headers and open a new one. Run your query in the newly opened window and see if it now saves with column headers.

Note: the same option is available for Results to Text if you are not using Results to Grid.

like image 98
squillman Avatar answered Oct 31 '25 03:10

squillman


@destination-data You got me on the right track. I restarted Management Studio and since then I get the save as results as specified in the options. Kinda embarrassing that I didn't think of restarting. Worked fine for days.

Added to mark this as answer.

like image 33
Ramon S Avatar answered Oct 31 '25 04:10

Ramon S