sql-server - 为什么我在 SQL Server 中尝试发送电子邮件时收到错误 -2147467259
问题描述
我正在尝试发送一封电子邮件,其中包含 SQL Server 中存储过程调用的结果。
declare @querytext nvarchar(100)
set @querytext = 'sp_get_SPresults @item_name = ''Name of Group'''';
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'My Email',
@recipients = 'anaddress@adomain.com',
@body = 'Email',
@subject = 'Suitable Subject' ,
@query = @querytext,
@attach_query_result_as_file = 1,
@query_result_header = 1,
@query_no_truncate = 1;
但是当我运行这个时,我得到一个
消息 22050,级别 16,状态 1,第 23 行无法初始化 sqlcmd 库,错误号为 -2147467259 错误。
当我在 SQL Server 中发送测试电子邮件时,它可以正常发送。即使只是设置@querytext
为"select * from [Table]"
不起作用。我在其他地方看到 include@query_result_header=1
可以解决此类问题,但在这里似乎没有什么不同。
任何帮助,将不胜感激。
谢谢
解决方案
最后,无论出于何种原因,我尝试仅使用以下参数:
- @profile_name
- @recipients
- @身体
- @学科
- @body_format
- @execute_query_database
这现在有效。感谢大家的帮助。:)
推荐阅读
- javascript - React Native Customized Image Picker 不在 android 上显示图库图片
- python - 将 uuid 序列化为其字符串表示形式
- python - 屏蔽矩阵某些行的少数非零元素
- taglib - taglib 读取 1464 mp3 文件太慢
- excel - 通过 Excel ping 多台计算机,并在单独的列中具有 IP 地址
- javascript - onclick 在页面加载时触发
- python - 需要读取一百万个文件以获得时间戳并根据时间戳移动其文件夹中的文件......哪种方法最快?
- javascript - 如何在 django 中对外键应用搜索过滤器?
- machine-learning - Python中的方差-通货膨胀因子
- javascript - 对前端显示的数据量有限制