Thursday, July 25, 2013

Save results with headers in SQL Server Management Studio

I am working a lot with excel and CSVs for my SSIS packages these days. so I need to some input files as CSV files from SQL Server. Here is what I did in SQL Server Management Studio to get CSV files with Headers
  1. Go to Tools in SQL Server Management Studio and click options.
  2. Now click on Query Results and select SQL Server.
  3. Now go to Results to Grid.
  4. Select “Include column headers when copying or saving the results. (shown in below image)
  5. Click OK
  6. Restart SQL Server Management Studio and you are good to go now.
 image Now open your query window and write you query and execute. On the results window right click and select  "save results as" and then save to CSV file which I can open in excel. 


No comments:

Post a Comment