Query Output

  • How do you run a stored procedure and direct its output to a text file or even an nvarchar string?

    Thanks

  • are you trying to do this once in a while or every time an sp fires?

  • One option would be to execute the stored procedure via OSQL and then use the -o option to output the results to a file.

    You can also get the output into a table doing something like this:

    Create table #output (output varchar(1000))

    insert into #output exec(your_sp)

    Gregory Larsen, DBA

    If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples

    Gregory A. Larsen, MVP

  • I need to do this everytime the sp fires. In fact the sp is going to be scheduled as a job. The result is to be emailed.

  • I have a weekly scheduled job that has 3 steps using procs to update a database. 3 more steps, each using isql to extract data from the tables updated to text files. Another step to zip the text files and the last step to email.

    You could some similar to this.

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Thanks for your suggestion. I have decided to use the isql as suggested.

  • DavidBurrows, which email system do you use mapi, CDONTS, SQL Server, etc. ?

    Any suggestions

  • SQL7 SP4 xp_sendmail with Outlook 2000. Could not use cdosys and SMTP as the email has to be sent externally and our Exchange server does not act as a relay for security reasons.

    Far away is close at hand in the images of elsewhere.
    Anon.

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply