Sam OZ
asked on
Sql Server batch script to write multiple query results to excel/text files
need to run several Sql Server 2014 select queries and write the results to excel sheets
Example
select docname from TbDocs where plant = 'Plant1' - Write to Plant1.xlsx
select docname from TbDocs where plant = 'Plant2' - Write to Plant2.xlsx
select docname from TbDocs where plant = 'Plant3' - Write to Plant3.xlsx
.. has 20 plants total
I need this Each plant data going to separate excel files , due to some requiremnt
(NOTE: It can be text files instead of excel files, If I can read it in excel later)
Can I have a batch sql script running and writing it to 20 Plant excel files in one shot?
Example
select docname from TbDocs where plant = 'Plant1' - Write to Plant1.xlsx
select docname from TbDocs where plant = 'Plant2' - Write to Plant2.xlsx
select docname from TbDocs where plant = 'Plant3' - Write to Plant3.xlsx
.. has 20 plants total
I need this Each plant data going to separate excel files , due to some requiremnt
(NOTE: It can be text files instead of excel files, If I can read it in excel later)
Can I have a batch sql script running and writing it to 20 Plant excel files 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.