数据库邮件服务器中sp_send_dbmail的参数使用
时间:2021-07-01 10:21:17
帮助过:1人阅读
配置数据库邮件完毕之后
--其中 l_test 为配置文件名 ,Test为邮件主题名 ,邮件正文内容body,邮件中查询结果 query ,my_test 是附件名
--查询结果放在正文之中
EXEC msdb.dbo.sp_send_dbmail
@profile_name = ‘l_test‘,
@recipients = ‘lxxxx@xx.cn‘,
@subject = ‘Test‘,
@body = ‘the query is :‘,
@query = ‘SELECT TOP 10 [ID],[user_id],[date_time] FROM [xxx].[dbo].[xxx] where [date_time] > "2011-06-20 09:52:40.730" order by ID asc‘,
@attach_query_result_as_file= 0
--查询结果放在附件之中
EXEC msdb.dbo.sp_send_dbmail
@profile_name = ‘l_test‘,
@recipients = ‘xxx@xx.cn;xxxx@qq.com‘,
@subject = ‘Test‘,
@body = ‘the query is in fujian‘,
@query = ‘SELECT TOP 10 [ID],[user_id],[date_time] FROM [xxxDB.[dbo].[xxxxx] where [date_time] > "2011-06-20 09:52:40.730" order by ID asc‘,
@attach_query_result_as_file= 1,
@query_attachment_filename= ‘my_test‘
数据库邮件服务器中sp_send_dbmail的参数使用
标签: