Sql 通过数据库邮件发送文件
我试图通过数据库邮件发送一个文件,当我执行下面的查询时,没有触发@query选项邮件,但是当我包含@query选项时,我得到了上面提到的错误Sql 通过数据库邮件发送文件,sql,sql-server,sql-server-2008,tsql,Sql,Sql Server,Sql Server 2008,Tsql,我试图通过数据库邮件发送一个文件,当我执行下面的查询时,没有触发@query选项邮件,但是当我包含@query选项时,我得到了上面提到的错误 if @@rowcount >0 EXEC msdb.dbo.sp_send_dbmail @profile_name = ' Errormail',@recipients='arunkumarb@mobiusservices.in;', @subject = 'A new Record created in
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'.
提前感谢尝试为表使用完全限定名:
SELECT * FROM yourDatabase.yourSchemaName.ip
您还可以将调用sp\u send\u dbmail
的@execute\u query\u database
参数设置为包含数据库的名称(尽管我认为使用完全限定的名称就足够了)