SQL Mail (sp_send_dbmail)

Last Post 18 Mar 2011 11:00 AM by russellb. 3 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
KXD
New Member
New Member

--
18 Mar 2011 07:39 AM
If I have a maintenance plan (which runs everyday) which put out a report on index stat's and other DBCC information, The report come to me and other operators with the report information in the body of the email. How can I have the report come as an attachement instead? I tried sp_send_dbmail, I guess I'm using the wrong parameter.
rm
New Member
New Member

--
18 Mar 2011 07:43 AM
It has parameter @file_attachments .
KXD
New Member
New Member

--
18 Mar 2011 08:00 AM
I know about the @file_attachment but when the file name is changing everyday (FilenameMM/DD/YYYY), THE @file_attachment will have to be able to change each time as well.
russellb
New Member
New Member

--
18 Mar 2011 11:00 AM
That's not the naming convention of your file -- the slashes aren't valid in a filename.

I use this ccyymmdd for all file names.
 <br />  <br /> If you need MMDDYYYY then this will do it[CODE]Declare @filename CHAR(16)
SET    @filename = 'Filename' +
    Right('0' + Convert(varchar(8), DatePart(month, getdate())), 2) +
    Right('0' + Convert(varchar(8), DatePart(day, getdate())), 2) +
    CONVERT(char(4), DatePArt(year, getdate())) 


If the date is yesterday, change the getdate() to getdate()-1 or use dateadd function
You are not authorized to post a reply.

Acceptable Use Policy