automatic job to generate a attached databases report and sent mails using sql mails

  • Hi,

    I need to use this script ,.. select * from master.dbo.sysdatabases->use SQL DatabaseMail to send it to

    whomever they require.

    Could you please let me know how to do that

    I have created a job and it is running succcessfully, taht resuly i need to sent

    using SQL Database mail

    Please help me to do this

    Smm

  • EXEC msdb.dbo.sp_send_dbmail @profile_name = 'MyProfile'

    , @recipients = 'me@mydomain.com'

    , @subject = 'subject text'

    , @body = 'subject body'

    , @query = 'select * from master.dbo.sysdatabases'

    , @attach_query_result_as_file = 1

    , @execute_query_database = 'master'

    BTW, this is all in BOL.

  • Hi,

    Thanks ,is it possible to get the result in Excel,I am getting the result in .text format

    Please help me

  • shine.mm (4/1/2008)


    Hi,

    Thanks ,is it possible to get the result in Excel,I am getting the result in .text format

    Please help me

    Have a look at using the @query_result_separator and using a comma seperator. Then you might be able to open it in Excel as a csv.

    An alternative could be to use SSIS to output to a .csv file, which you then email.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply