The manual way, if in SQL Server Management Studio (SSMS) you simply select rows and columns and paste it into Excel, or you can right-click and save as a CSV file and open it in Excel.
To get the headers you want:
- Select the Service option.
- Click Options → Query Results → Sql Server → Results for Grid
- Tick Include column headers when copying or saving results.
Then make your copy and paste.
source share