-1

I am trying to export SQL server query results to excel using power shell. My query runs on all the servers in a domain. My powershell query need to load results of each server to each page in 1 Excel sheet. Please suggest

1 Answers1

0

What I suggest you can do is get the results of the SQL query from each server in individual csv files (by using export-csv command) and then combine each result in one single sheet. This link will be helpful. Copy Excel Worksheet from one Workbook to another with Powershell. Although a bit lengthy but it will serve your purpose.

Community
  • 1
  • 1
Vivek Kumar Singh
  • 3,223
  • 1
  • 14
  • 27
  • Thank you Vivek. Will check this out – user6849192 May 09 '17 at 05:50
  • Hi Vivek, I got stuck up with one more issue. I am able to export multiple CSV's in to One excel sheet successfully. That excel sheet is again forwarded to my email for further evaluation. This is done in TEST environment successfully . I tried to implement same in production, unfortunately I don't have MS Office installed on that server. Is there a other way I can solve this – user6849192 Nov 11 '17 at 09:42
  • I had the same issue with my production environment. We got MS Office installed on it. But initially, I went through [this](http://ramblingcookiemonster.github.io/PSExcel-Intro/) and [this](https://blogs.technet.microsoft.com/pstips/2014/06/02/get-excel-data-without-excel/). After we got Office installed, my problems were solved. May be you can find those links useful. – Vivek Kumar Singh Nov 11 '17 at 19:31
  • Thank you vivek for sharing the links. Here My concern is I need to merge the CSV's into one excel. When MS office is installed on my server, I was able to do that . Now there is no MS Office installed on the server and I need merge all CSV's to one Excel. I ll go through the links you shared. Please share me if you find any other useful links – user6849192 Nov 22 '17 at 09:39