I have searched around but cannot find an answer to this so any help is appreciated. I have a 2014 server with dual instances. When I execute the following query , it succeeds on one instance but fails on the other with the above error. This is not related to SQL Agent, this fails on query execution within SSMS as well (on instance 2, succeeds on instance 1). Names have been changed to generic below. I have tried with/without various options in the call, nothing seems to work on instance 2, but works fine on instance 1. IF I remove the @query parameter, I DO receive the email.
EXEC msdb.dbo.sp_send_dbmail
@profile_name ='Profile1',
@recipients = 'recipientlist',
@subject ='Error in rules-PLEASE INVESTIGATE-',
@body ='There is an error in rules, a rule calls itself. Please fix. The broken rule id is:',
@query='select fields from table WHERE [RuleOnSuccess] = [RuleID] OR [RuleOnFailure] = [RuleID] ',
@attach_query_result_as_file = 0;