程序出错,sql 无法发送邮件

got an error on an procedure, sql send mail not working

所以,我有这个程序的代码。代码如下:

EXEC msdb.dbo.sp_send_dbmail  
    @profile_name = 'SQL-PHC',  
    @recipients = 'filipeferreira@mass.pt',  
    @query = 'SELECT no, nome, obrano, convert(varchar,datafinal)  
    FROM bo
    WHERE nmdos LIKE "Preços por Cliente"
    AND datafinal = DATEADD(day, -1, CONVERT(date, GETDATE()))' ,  
    @subject = 'Work Order Count',  
    @attach_query_result_as_file = 1 ;

当我解析代码时,一切正常,但是当我执行它时,出现以下错误:

Msg 22050, Level 16, State 1, Line 0
Failed to initialize sqlcmd library with error number -2147467259.

我真的不明白这是怎么回事或如何解决这个问题

好吧,终于做对了。使用探查器后,我发现错误出在查询上,因此只需将数据库名称添加到 "from" 即可解决。 无论如何谢谢大家