Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Manager -- Start a New Output File

Status
Not open for further replies.

ajc123

Programmer
Oct 6, 2001
25
0
0
US
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:
If you want to get the best answer for your question read faq183-874.
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top