Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Save multiple result sets to one file??

Author  Topic 

phrankbooth
Posting Yak Master

162 Posts

Posted - 2007-08-09 : 15:22:18
Hello,

Is it possible to save the results of several SP calls in a script, to one file?

Here's what I mean:
I want to run these 4 sp calls--
exec EPC_SP1 'aph','live'
exec EAUI_SP2 'noble','newswire'
exec EAUI_SP3 'noble',1
exec EAUI_SP4 5507,'live'

And save the results of each one of those calls to the same file, in other words, an APPEND

Is this or something like it possible in TSQL?

Help appreciated!

Thank you,
--PhB

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-08-09 : 15:56:56
You can do this through the GUI tools by simply doing a Save As, just run all 4 at the same time. You could alternatively do this through the command line. Use sqlcmd for 2005 and osql for 2000.

osql -Sserver1 -iC:\SomeScript1.sql >C:\OutputFile.txt
osql -Sserver1 -iC:\SomeScript2.sql >>C:\OutputFile.txt
osql -Sserver1 -iC:\SomeScript3.sql >>C:\OutputFile.txt
osql -Sserver1 -iC:\SomeScript4.sql >>C:\OutputFile.txt

> writes all output from the command to a new file or overwrites an existing file. >> appends all output to the file. > and >> are not part of the osql or sqlcmd command but rather it is a DOS option.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-09 : 16:01:20
INSERT .. OPENROWSET( ..., 'EXEC ...')
INSERT .. OPENROWSET( ..., 'EXEC ...')
INSERT .. OPENROWSET( ..., 'EXEC ...')



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

phrankbooth
Posting Yak Master

162 Posts

Posted - 2007-08-09 : 16:18:50
Cool, thanks. I ended up using sqlcmd which seems to be faster.

--PhB
Go to Top of Page
   

- Advertisement -