Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
DBA007
Posting Yak Master
145 Posts |
Posted - 2010-02-08 : 16:15:51
|
HI,does any one have idea on sending the sqljob output as a mail attachment. |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
DBA007
Posting Yak Master
145 Posts |
Posted - 2010-02-09 : 06:15:07
|
thanks tara,but i need the tsql to be used in the job for sending the job output as a mail attachment,the first step of the job executes a script and writes to a file,and the second step has to send this output as a mail attachment.the job must also delete the contents of the output file every time it runs. |
 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
vmenon
Starting Member
17 Posts |
Posted - 2010-02-11 : 06:27:37
|
Step 1 of Agent job executes a script ans writes to a file e.g. c:\QueryOutput.txtStep 2 of Agent job needs to excute the below query to send the attachment mail. To send e-mail in Plain Text and also attachements:EXEC sp_send_dbmail @recipients = 'SQLDBA@dba.com',@subject = 'Please find the QueryOutput',@body = 'Please find the QueryOutput in the attached file',@body_format = 'TEXT',@file_attachments = 'c:\QueryOutput.txt'To send e-mail in MIME and also attachements:EXEC sp_send_dbmail @recipients = 'SQLDBA@dba.com',@subject = 'Please find the QueryOutput',@body = 'Please find the QueryOutput in the attached file',@body_format = 'HTML',@file_attachments = 'c:\QueryOutput.txt' |
 |
|
|
|
|
|
|