Question: how to export data from sql server 2012 to excel using query?
Answer: Go to Tools->Options.
Query Results->SQL Server->Results to Grid.
Check “Include column headers when copying or saving results”
Click OK.
Note that the new settings won't affect any existing Query tabs — you'll need to open new ones and/or restart SSMS.