Multiple attachments using sp_sendSAM

  • I am writing a stored procedure to be able to deliver data that comes from 2 separate queries. I want that data e-mailed in an excel spreadsheet (either in 2 separate excel files or in one file on 2 separate tabs). I am able to get it delivered fine using only one of the queries but when I try to run it with both queries, it does not run correctly. The SP is below.

    BEGIN

    SET NOCOUNT ON;

    DECLARE @Sender AS varchar(255)

    DECLARE @Recipient AS varchar(255)

    DECLARE @qry as varchar(8000)

    DECLARE @Subject as varchar(200)

    DECLARE @Message as varchar (500)

    SET @Sender = 'John Doe '

    SET @Recipient = 'John Doe '

    SET @Subject = 'Testing'

    SET @Message = 'Message - Testing '

    SET @qry =

    'SELECT *

    FROM Server.dbo.Table

    where Variance < 0

    order by Number

    SELECT *

    FROM Server.dbo.Table

    where Variance > 0

    order by Number'

    EXEC Robots.dbo.sp_SendSAM

    @sender_email = @Sender,

    @recipients = @Recipient,

    @Subject = @Subject,

    @Message = @Message,

    @Query = @qry,

    @Attach_Results = 'true',

    @Attachment_Format = 'XLS'

    END

    I am not even sure if I can do this. If not, I know I can always create 2 SP's that will send 1 e-mail each but I am trying to avoid that.

  • Have you checked the following link?

    http://www.sqlanswers.com/Software/SAM/SAMOnlineDemo.aspx?demo=10

    "Got no time for the jibba jabba!"
    -B.A. Baracus

Viewing 2 posts - 1 through 1 (of 1 total)

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