• cunningham (12/19/2012)


    Thanks for this, put me on the right track. but I had to change the database in the drop down to MSDB rather than master or any other. my query just called fully qualified stored proc names. similar to below

    EXEC msdb.dbo.sp_send_dbmail @profile_name='mickey profile',

    @recipients='mickey.mouse@disney.com;',

    @subject='Subject of email',

    @query= '

    print ''Description of email''

    print ''''

    exec DBNAME.dbo.SPName

    print ''''

    print ''---------''

    etc

    etc

    '

    I know this is an old thread but setting the database in the dropdown to 'msdb' fixed the same problem for me. Most of the solutions you find when you try to google this reference most of the items found earlier in this thread.

    Also, I have @execute_query_database='MyDatabaseName' added to sp_send_dbmail to insure the database is switched to the location of my stored procedure.