Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Multiple attachments using sp_sendSAM


Multiple attachments using sp_sendSAM

Author
Message
clostio33
clostio33
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 143
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.
the__t
the__t
SSC Veteran
SSC Veteran (268 reputation)SSC Veteran (268 reputation)SSC Veteran (268 reputation)SSC Veteran (268 reputation)SSC Veteran (268 reputation)SSC Veteran (268 reputation)SSC Veteran (268 reputation)SSC Veteran (268 reputation)

Group: General Forum Members
Points: 268 Visits: 419
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search