Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2007
    Posts
    86

    Unanswered: sp_send_dbmail, attache a file on file system - HOW?

    Is there any way to attach a file on the file system from sp_send_dbmail?

    job code:
    use master
    go
    xp_cmdshell 'D:\scripts\run_purge_WFINSTANCE.bat'
    go
    EXECUTE msdb.dbo.sp_send_dbmail
    @recipients=N'sasher@montefiore.org',
    @body='Report saved to: D:\reports\purge_WFINSTANCE.txt ',
    @subject ='MS-ALERT- TREKSPBDSQL.monte_prod: purge_WFINSTANCE run details',
    @profile_name ='TREKSadmin'
    go

    the xp_cmdshell runs the bat file which ivokes sqlcmd with results posted to a local file system. The job works, but I'd like the results (counts) emailed to all dba's.

    Any idea how this is done?


    runnig SS05/SP3 64bit on blades.

  2. #2
    Join Date
    Jun 2004
    Location
    Long Island
    Posts
    696
    sp_send_dbmail [ [ @profile_name = ] 'profile_name' ]
    [ , [ @recipients = ] 'recipients [ ; ...n ]' ]
    [ , [ @copy_recipients = ] 'copy_recipient [ ; ...n ]' ]
    [ , [ @blind_copy_recipients = ] 'blind_copy_recipient [ ; ...n ]' ]
    [ , [ @from_address = ] 'from_address' ]
    [ , [ @reply_to = ] 'reply_to' ]
    [ , [ @subject = ] 'subject' ]
    [ , [ @body = ] 'body' ]
    [ , [ @body_format = ] 'body_format' ]
    [ , [ @importance = ] 'importance' ]
    [ , [ @sensitivity = ] 'sensitivity' ]
    [ , [ @file_attachments = ] 'attachment [ ; ...n ]' ]
    [ , [ @query = ] 'query' ]
    [ , [ @execute_query_database = ] 'execute_query_database' ]
    [ , [ @attach_query_result_as_file = ] attach_query_result_as_file ]
    [ , [ @query_attachment_filename = ] query_attachment_filename ]
    [ , [ @query_result_header = ] query_result_header ]
    [ , [ @query_result_width = ] query_result_width ]
    [ , [ @query_result_separator = ] 'query_result_separator' ]
    [ , [ @exclude_query_output = ] exclude_query_output ]
    [ , [ @append_query_error = ] append_query_error ]
    [ , [ @query_no_truncate = ] query_no_truncate ]
    [ , [ @mailitem_id = ] mailitem_id ] [ OUTPUT ]

  3. #3
    Join Date
    Mar 2007
    Posts
    86

    sp_send_dbmail with file attachment

    Thank YOU! That's exactly what I was looking for .. you're much faster than "the" google.. LOL

  4. #4
    Join Date
    Jun 2004
    Location
    Long Island
    Posts
    696
    Quote Originally Posted by stuarta
    Thank YOU! That's exactly what I was looking for .. you're much faster than "the" google.. LOL

    I use "noocular" power.

  5. #5
    Join Date
    Mar 2007
    Posts
    86

    sp_send_dbmail with nucular attachment

    BWAAHA HAHHHHAHA

    nice riposte ..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •