Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Multiple attachments using sp_sendSAM Expand / Collapse
Author
Message
Posted Monday, May 19, 2008 11:26 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, November 25, 2013 8:12 AM
Points: 5, Visits: 123
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.
Post #503006
Posted Monday, May 19, 2008 11:37 AM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Friday, April 30, 2010 9:49 AM
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
Post #503012
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse