是否可以将列中的数据导出到json和email中?
列是存储整个json字符串的NVARCHAR(MAX)。
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'Profile',
@recipients = 'a@b.com',
@subject = @Subject,
@body = @Body,
@query = 'SELECT TOP(1) [col] FROM [dbo].[tbl] ORDER BY [Date] DESC;',
@execute_query_database = 'DBName',
@attach_query_result_as_file = 1,
@query_attachment_filename = 'Report.json';
执行出错:
无法初始化sqlcmd库,错误号为-2147417850。
1条答案
按热度按时间pgvzfuti1#
是的,有可能。看起来您缺少所需的权限(Executing sp_send_dbmail with an Agent Job: Failed to initialize sqlcmd library)和@recipients参数。