我正在尝试通过数据库邮件发送文件,当我执行下面的查询时没有@query选项邮件被触发但是当我包含@query选项时我得到了提到的错误。
if @@rowcount >0
EXEC msdb.dbo.sp_send_dbmail @profile_name = ' Errormail',@recipients='arunkumarb@mobiusservices.in;',
@subject = 'A new Record created in the SSORunError Log Table' ,
@body = 'A new Record created in the SSORunError Log Table' ,
@query = 'select * from ip',
@attach_query_result_as_file = 1,
@query_result_width = 4000,
@query_attachment_filename = 'Details.txt'
错误消息:
Msg 22050, Level 16, State 1, Line 0
Error formatting query, probably invalid parameters
Msg 14661, Level 16, State 1, Procedure sp_send_dbmail, Line 504
Query execution failed: Msg 208, Level 16, State 1, Server , Line 1
Invalid object name 'ip'.
提前致谢
答案 0 :(得分:2)
尝试使用表格的完全限定名称:
SELECT * FROM yourDatabase.yourSchemaName.ip
您还可以将@execute_query_database
调用sp_send_dbmail
参数设置为包含数据库的名称(尽管我认为使用完全限定名称就足够了。)