I have several SQL reports I want to run from a single script file. I'd like the output from different reports to go to different files. I can't find a script command to do this.
If you don't know the answer, can you tell me where to look?
If you refer to a SQL script that executes several queires, then I don't know any way to send each SELECT result to a different file. T-SQL doesn't even have a command to send output to a file. You do have some choices.
1) Create a DTS package for each SELECT query that exports the result of query to a text file.
2) Use OSQL or ISQL to execute each SELECT query and direct the output to the specified files. The OSQL execution could be in a BAT file or in CmdExec steps of a SQL Agent Job.
3) Execute BCP using the QUERYOUT option for each query.
There are other mehods but this should give you some ideas. Terry L. Broadbent - DBA
SQL Server Page:
Thanks, Terry. I was wondering if Query Manager supported the old command line instructions, but didn't know what the BCP commands were. Turns out QM does not support the BCP commands.
A temporary solution has been to build a Job Stream, but it's slow going because I have to go through the GUI with two tabs rather than just pasting commands into a single script file.
This is something I do fairly often, so I wanted it to be quick.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.