Sam OZ
asked on
Write multiple sql server count query result to a single excel file
I need to run several select queries(Sql Server 2014 ) and write the results to an excel sheet
Example
select count(docname) from TbDocs where plant = 'Plant1' ------ Write "Plant1" in first column , count in second column of first row
select count(docname) from TbDocs where plant = 'Plant2' ----- Write "Plant2" in first column , count in second column of second row
select count(docname) from TbDocs where plant = 'Plant3' ----- Write "Plant3" in first column , count in second column of third row
.. has 20 plants total
(It is desirable, If I can have a header row as first row . But not a must)
Can I have a batch sql script running and writing it to a PlantCount excel file in one shot?
Example
select count(docname) from TbDocs where plant = 'Plant1' ------ Write "Plant1" in first column , count in second column of first row
select count(docname) from TbDocs where plant = 'Plant2' ----- Write "Plant2" in first column , count in second column of second row
select count(docname) from TbDocs where plant = 'Plant3' ----- Write "Plant3" in first column , count in second column of third row
.. has 20 plants total
(It is desirable, If I can have a header row as first row . But not a must)
Can I have a batch sql script running and writing it to a PlantCount excel file in one shot?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window