首页 > 代码库 > SQL Server 2005 sp_send_dbmail出现Internal error at FormatRowset (Reason: Not enough storage is available to complete this operation)
SQL Server 2005 sp_send_dbmail出现Internal error at FormatRowset (Reason: Not enough storage is available to complete this operation)
案例环境:
操作系统: Windows 2003 SE 32bit(SP2)
数据库版本:Microsoft SQL Server 2005 - 9.00.5069.00 (Intel X86)
Aug 22 2012 16:01:52
Copyright (c) 1988-2005 Microsoft Corporation
Standard Edition on Windows NT 5.2 (Build 3790: Service Pack 2)
案例分析:
如下所示,使用下面SQL语句发送邮件时,遇到一个非常奇怪的错误信息:Not enough storage is available to complete this operation
EXEC msdb.dbo.sp_send_dbmail @recipients = ‘konglb@xxx.com‘,
@subject = ‘it is only test‘, @body = NULL, @body_format = ‘text‘,
@query_result_separator = ‘---‘,
@query = ‘SELECT * FROM MESDB.dbo.MES_DAILY_CLOSING_LOG‘;
Msg 22050, Level 16, State 1, Line 22
Error formatting query, probably invalid parameters
Msg 14661, Level 16, State 1, Procedure sp_send_dbmail, Line 517
Query execution failed: Sqlcmd: Error: Internal error at GetDataRowset (Reason: Not enough storage is available to complete this operation).
Sqlcmd: Error: Internal error at FormatRowset (Reason: Not enough storage is available to complete this operation).
错误虽然提示storage not engough,其实这个错误跟存储没有任何关系,这个表MES_DAILY_CLOSING_LOG里面有三个字段为NVARCHAR(MAX),采取下面两种方式可以临时解决这个问题。
1: 如果在@query里面排除这三个NVARCHAR(MAX)字段,那么邮件正常发送,不会出现任何错误。
2: 如果在@query里面将这个字段做一下转换,例如CAST(MAIL_RECEIPS AS NVARCHAR(4000)),那么邮件也能正常发送。
在SQL Server 2008、 SQL Server 2012下都不会发生,另外在SQL Server 2005(9.00.5000.00)这个版本下测试,也没有出现这个问题。只有这台服务器会出错,后面在这篇sp_help_jobsteplog fails when run as a @query of sp_send_dbmail文章里面反馈,重启数据库服务后,就不会出现这个问题。等了一周等到一个合适的时机重启了服务器,验证发现重启过后,果然这个错误就消失了。网上关于这个错误的资料非常少,严重怀疑是触发了某一个Bug。
参考资料:
https://social.msdn.microsoft.com/Forums/en-US/0882f984-58f4-4a2a-8d0c-5f2c1e3cc853/msdbdbospsenddbmail-error?forum=transactsql
http://dba.stackexchange.com/questions/3591/sp-help-jobsteplog-fails-when-run-as-a-query-of-sp-send-dbmail
SQL Server 2005 sp_send_dbmail出现Internal error at FormatRowset (Reason: Not enough storage is available to complete this operation)