Hi,
Hopefully someone can help shed some light on this.
I have a task set up that runs the following:
EXEC msdb.dbo.sp_send_dbmail @Profile_name='ProfileName', @recipients='ToAddress@Address', @subject='Hello', @query = 'Execute AS user = SA set nocount on select DatatoSend as DatatoSend from Database.dbo.DataSendQueue', @attach_query_result_as_file=0, @query_result_width =32767, @query_no_truncate=1, @query_result_header = 0;
Now the issue is this. This worked perfectly when we were running SQL Server 2012, no errors and the email was sent every time.
We have upgraded to SQL Server 2014 and now it fails. with the error:
Msg 22050, Level 16, State 1, Line 0
Failed to initialize sqlcmd library with error number -2147024809.
If I comment out the @query line the email sends without any issues. I can't find any other errors and can't get my head around what might have changed when we upgraded versions.
Pete