March 2, 2020 at 8:20 pm
I'm having trouble trying to get my query results loaded into my excel attachment can anyone help.
DECLARE @sub VARCHAR(100)
DECLARE @qry VARCHAR(1000)
DECLARE @msg VARCHAR(250)
DECLARE @query NVARCHAR(1000)
DECLARE @query_attachment_filename NVARCHAR(520)
SELECT @sub = 'DC Weekly Transfer'
SELECT @msg = 'This is Just a test.'
SELECT @query_attachment_filename = 'dcweekly.csv'
Declare @nOrgID int = 67
, @startdate date = dateadd(wk, -1, dateadd(wk, datediff(wk, 0, getdate()), -1))-- for saturday
, @enddate date = dateadd(wk, datediff(wk, 0, getdate()), -2) --for sunday
, @nDonationTypeID int = 4;
Select ld.nStartLocationID
, ld.nEndLocationID
, ld.nDonorCount
, ld.tEffectiveDate
, ld.cChangedBy
From dbo.Data_Org_Location_Donations ld
Where ld.nOrganizationID = @nORGID
And ld.nDonationTypeID = @nDonationTypeID
And ld.nactive = 1
And ld.tEffectiveDate >= @startdate
And ld.tEffectiveDate < dateadd(day, 1, @enddate)
Order By
ld.tEffectiveDate;
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'WESA DC Weekly',
@recipients = 'edward.vahovick@gimi.org',
@subject = 'Multiple file attachments in SQL Server DBMail',
@body = 'DC Weekly Email Results',
@file_attachments = 'C:\dcweekly.csv'
March 2, 2020 at 10:28 pm
The changes you need are already in one of your other posts on this issue - refer to:
https://www.sqlservercentral.com/forums/topic/ssis-83#post-3729844
Sue
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply