Urgent: how to save query result into a file

  • Hi folks,

    I want to run a DTS package, in the package, I run a query which will return me some data, I want to use the data as an attachment in the SQL mail and send back to me.

    Is that possible? if yes, how to do that?

    Thanks.

     

     

     

  • transform the data from the query to a file and then use that file as an attachment to send the mail...

    -Krishnan

  • I don't know if this will help, but you could setup a job that sends you an email using xp_sendmail that has the query in the send mail script.

    Schedule your DTS and create a second step with a script like the example below I got from BOL to email the results of the query to you as an attachment.

    EXEC xp_sendmail @recipients = 'robertk',    @query = 'SELECT * FROM INFORMATION_SCHEMA.TABLES',   @subject = 'SQL Server Report',   @message = 'The contents of INFORMATION_SCHEMA.TABLES:',   @attach_results = 'TRUE', @width = 250

     

     

Viewing 4 posts - 1 through 3 (of 3 total)

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